pagination issue

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!

Moderator: General Moderators

Post Reply
kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

pagination issue

Post 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]
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Post by thiscatis »

I think you need a WHILE statement there.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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);
kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

Post by kippy »

displays the following:

Array
(
[count] => 0
)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

No rows were matched given your criteria.
kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

Post by kippy »

ok, fixed that portion it now shows 25 results!
Post Reply