Chris.P Posted June 2, 2011 Share Posted June 2, 2011 I have the following code. Basically I'm trying to count the amount of colours returned in the $colour variable. What I have is always returning 1, any ideas why? $colour = $db->query("SELECT * FROM colours WHERE prod_id = ".$row['prod_id']." AND LENGTH(col_image_1) > 0 ORDER BY col_rank ASC LIMIT 1"); $colourcount = mysql_num_rows($colour); if($db->numrows($colour)) { $colour = $db->fetchrow($colour); } else { unset($colour); } echo $colourcount; Quote Link to comment https://forums.phpfreaks.com/topic/238201-counting-values-from-mysql/ Share on other sites More sharing options...
teynon Posted June 2, 2011 Share Posted June 2, 2011 LIMIT 1 in your sql query limits it to 1 every time. Quote Link to comment https://forums.phpfreaks.com/topic/238201-counting-values-from-mysql/#findComment-1224049 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.