thresher
01-22-2010, 12:42 PM
Firstly, I am a real MySQL noob, so sorry if this is really obvious!
I'm trying to get a page to display a list of items from a database, but only display 6 of those items per page.
I can get the mysql to return all the items or one of the items, but I'm trying to get it to just return the range I specify per page.
So on page 1 I want items 1-6 to show, so I've used the following code:
$sql = "SELECT unit_id, company_name, website, contact_name, phone_no, description
FROM details
WHERE unit_id='1'
ORDER BY unit_id";
Obviously this only displays the item 'unit_id 1'.
Is there a clause I can add to the WHERE clause to say "Get all items between unit_id 1 and 6"? Or am I using the wrong clause altogether?
I'm trying to get a page to display a list of items from a database, but only display 6 of those items per page.
I can get the mysql to return all the items or one of the items, but I'm trying to get it to just return the range I specify per page.
So on page 1 I want items 1-6 to show, so I've used the following code:
$sql = "SELECT unit_id, company_name, website, contact_name, phone_no, description
FROM details
WHERE unit_id='1'
ORDER BY unit_id";
Obviously this only displays the item 'unit_id 1'.
Is there a clause I can add to the WHERE clause to say "Get all items between unit_id 1 and 6"? Or am I using the wrong clause altogether?