Forum Moderators: coopster
One of the features is to display how many i.e dell Desktops are in the db, so im connecting to the db and counting the results in the SELECT query, problem is :
//DESKTOPS
$sqldesk = "SELECT * FROM goldline_products where brand = '$brand' AND prod_type = 'Desktop'";
$rsdesk = mysql_query($sqldesk);
$deskcount = mysql_num_rows($rsdesk);
echo "$deskcount";
that counts the results in the db no problem and then later in the page im echoing
Desktops ($deskcount) Laptops ($lapcount)
etc
so people can see how many are in the db.
Whats happening is when the result returns 0, the warning msg for num_rows is displayed all over the top of the page, all i want it to do is say ok there arent any so the variable = 0.
Help
Can i use a different function to count the array or something?
regards,
Diego
//DESKTOPS
$sqldesk = "SELECT * FROM goldline_products where brand = '$brand' AND prod_type = 'Desktop'";
$rsdesk = mysql_query($sqldesk);
if (mysql_num_rows == 0 ){
$deskcount ="0";
}else{
$deskcount = mysql_num_rows(rsdesk);
}
Grrrrrrr
[edited by: diegomh7 at 3:47 pm (utc) on July 4, 2006]
//DESKTOPS
$sqldesk = "SELECT * FROM goldline_products where brand = '$brand' AND prod_type = 'Desktop'";
$rsdesk = mysql_query($sqldesk);
$deskcount = mysql_num_rows($rsdesk) or ('');
seems to work, kind of do this or do nothing kind of approach.
hope this helps others with the same problem
regards,
Diego
One more thing,
"Well, you should monitor whether or not your query ran successfully! If you have an issue with your statement you should indeed be monitoring for these types of issues."
erm, great, any examples? I mean i do query stuff and echo results to see if things are working,
thanx in advance
Diego