Page 1 of 1

pagination issue

Posted: Thu Aug 16, 2007 12:31 pm
by kippy
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


sorry to ask but I am using the following code:

Code: Select all

//count number of records
		$query="SELECT COUNT(*) FROM Products WHERE category=\"$category_var\" and series=\"$series_var\"";
		$result=mysql_query($query);
		$row=mysql_fetch_array($result); 
		$num_records = $row[0];
and when I echo $num_records I get a 0, which isn't right...any thoughts?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Aug 16, 2007 12:34 pm
by thiscatis
I think you need a WHILE statement there.

Posted: Thu Aug 16, 2007 12:49 pm
by John Cartwright
Lets start simple, run the following and tell us the output

Code: Select all

//count number of records
$query="SELECT COUNT(*) as `count` FROM Products WHERE category=\"$category_var\" and series=\"$series_var\"";
$result=mysql_query($query) or die('Failed on SQL: "'. $query.'". Reason: '. mysql_error());
$row=mysql_fetch_assoc($result);
echo '<pre>';
print_r($row);

Posted: Thu Aug 16, 2007 12:52 pm
by kippy
displays the following:

Array
(
[count] => 0
)

Posted: Thu Aug 16, 2007 12:54 pm
by John Cartwright
No rows were matched given your criteria.

Posted: Thu Aug 16, 2007 1:01 pm
by kippy
ok, fixed that portion it now shows 25 results!