• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

PHP counting issue

SarcasticDwarf

Diamond Member
I have a search script that displays the number of returned hits. At the top of every page it shows:

Results X - Y of a total of Z


The problem I have is it always says 0-50 on the first page, even when there are less than 50 results (the maximum number is correctly calculated).

The code to display is print "$listnext - " . ($listnext + $listlimit) .

The generating code is:
$surch = htmlspecialchars($_GET["item"]);
$listnext = $_GET["next"] or $listnext = 0;
$listlimit = 50;



Damned if I can figure out how to get the correct number to show when the value is less than 50. I can see where the problem is, I just don't know how to fix something like that.
 
there are several well written php classes out there, i'd download one and use it.

otherwise you can probably just

if(50 < mysql_num_rows($yourQueryResource))
$listnext = mysql_num_rows($yourQueryResource);
 
Back
Top