Page 2 of 2

Posted: Tue Sep 09, 2003 10:47 am
by AaronSmith
Look towards the end of my code...

Code: Select all

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?

Posted: Tue Sep 09, 2003 11:10 am
by AaronSmith
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?

Did this cease to be fun? lol

Posted: Tue Sep 09, 2003 11:20 am
by JAM
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)

Posted: Tue Sep 09, 2003 11:29 am
by AaronSmith
It gives me nothing - not an error nor a response.

Posted: Tue Sep 09, 2003 11:50 am
by AaronSmith
As it were, this began as a URL question - could there possibly still be something wrong with the link itself....

browse.php?id=217&page=4

?

Posted: Tue Sep 09, 2003 1:47 pm
by JAM
No, it is correct.

Code: Select all

// index.php contains:
<pre>
<a href="index.php?id=217&page=4">Test Link</a>
<?php
show_source(__FILE__);
print_r($_GET);
?>

Array
(
    [id] => 217
    [page] => 4
)
Did you try global $start; ?

Posted: Tue Sep 09, 2003 2:10 pm
by AaronSmith
Yes, have tried Global Start - same results.

Posted: Tue Sep 09, 2003 2:20 pm
by JAM

Code: Select all

if ($page==''){ 
$page='1'; 
} 
// and looking at:
if ($page==''){ 
$page=1; 
}
You are using $page = '1';. Would that make $page a string, not an integer? What would a string do in the LIMIT clause?

Posted: Tue Sep 09, 2003 3:41 pm
by AaronSmith
I fixed the problem!!!!!!!!!!!!!!!!!!!

The start was simply in the wrong place!