PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
function class_search($cat,$pagelimit)
{
global $query_string;
$table = "classifieds";
$pagelimit = "2";
$strSQL = mysql_query("SELECT * FROM $table");
$totalrows = mysql_num_rows($strSQL);
$pagenums = ceil ($totalrows/$pagelimit);
if ($page==''){
$page='1';
}
$start = ($page-1) * $pagelimit;
$starting_no = $start + 1;
$space = " ";
return snarf_array('classifieds','ID','ID',
" WHERE (Category=$cat OR Category2=$cat OR Category3=$cat) "
. " AND Expires>" . time()
. " ORDER BY Created DESC LIMIT $start,$pagelimit" );
}
In the "function class_search($cat,$pagelimit)" part, shouldn't I have $start in there somehow? If I change LIMIT $start,$pagelimit to LIMIT 3,$pagelimit, the page starts at the third item. Is in just not being passed dynamically?
I took out the start and pagelimit in the function heading completely, both there and where it is called.
The problem is this, it will not show the next items in the database; regardless of what page I am on, it displays the last two items (since I am in DESC order).
I believe the code is correct but perhaps it just isn't in the right place. Your thoughts?
Just wondering what wrong with it.
If you right after the function heading makes a 'echo $start;', what will that give you?
Perhaps you need to global $start also (as similiar to the $query_string)