seany123 Posted June 16, 2009 Share Posted June 16, 2009 basically i want to echo how many people in my "players" table have a gang_id that is = to $gang['id'] that it if anyone can help that would be good. Quote Link to comment https://forums.phpfreaks.com/topic/162477-solved-counting-from-a-database/ Share on other sites More sharing options...
Cosizzle Posted June 16, 2009 Share Posted June 16, 2009 $count = 0; while (gang_id == $gang['id']) { $count+=1; } echo $count Quote Link to comment https://forums.phpfreaks.com/topic/162477-solved-counting-from-a-database/#findComment-857562 Share on other sites More sharing options...
Alex Posted June 16, 2009 Share Posted June 16, 2009 $result = mysql_query("Select COUNT(gang_id) FROM `players` WHERE gang_id='" . $gang['id'] . "'"); $row = mysql_fetch_assoc($result); echo $row['COUNT(gang_id)']; Quote Link to comment https://forums.phpfreaks.com/topic/162477-solved-counting-from-a-database/#findComment-857564 Share on other sites More sharing options...
cunoodle2 Posted June 16, 2009 Share Posted June 16, 2009 <?php $query = "Select COUNT(gang_id) FROM players WHERE gang_id = '".$gang['id']."';"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); echo "There are ". $row['COUNT(gang_id)'] ." results."; ?> Or something like that Quote Link to comment https://forums.phpfreaks.com/topic/162477-solved-counting-from-a-database/#findComment-857566 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.