sql problems with LIMIT

wxdqz

New Member
I have a system that is attempting to display user profiles on separate pages. 10 users to a page. So the code I have to do it is as follows:

***

$max_display=9;
if ($page) $start_at = (10 * ($page-1));
if (!isset($start_at)) $start_at = 0;
$limit = "$start_at, " . ($start_at + $max_display);

$result = mysql_query("SELECT * from moc WHERE gender='$gender' ORDER BY userid LIMIT $limit");

***

$page is a variable that is input to the page from a nav frame, meaning the nav page links to display.phtml?page=xx. $gender works the same way.

The idea is to show 10 users per page (10 boys or 10 girls, as the case may be). Only it's going totally haywire! It's displaying 10 on the first page then 17 on the next, then the last 7 from page 2 on page 3. I have *NO* idea what's going on.

I'm wondering if part of it might be because some userids are missing. I could have sworn userid was auto_increment primary key not null, but it seems some userids aren't showing up.

Anyone have any ideas?
 
Back
Top