Dethman Posted July 9, 2008 Share Posted July 9, 2008 <?php if($player['raceID']==1){ $q = "select `username` from `user_users` where vote_count=(SELECT MAX(`vote_count`) FROM `user_users` where `raceID`='1')"; $leader = mysql_query($q) or trigger_error(mysql_error()); if( $leader ){ echo($leader); } else{ echo('None'); } } if($player['raceID']==2){ $q = "select `username` from `user_users` where vote_count=(SELECT MAX(`vote_count`) FROM `user_users` where `raceID`='2')"; $leader = mysql_query($q) or trigger_error(mysql_error()); if( $leader ){ echo($leader); } else{ echo('None'); } } if($player['raceID']==3){ $q = "select `username` from `user_users` where vote_count=(SELECT MAX(`vote_count`) FROM `user_users` where `raceID`='3')"; $leader = mysql_query($q) or trigger_error(mysql_error()); if( $leader ){ echo($leader); } else{ echo('None'); } } if($player['raceID']==4){ $q = "select `username` from `user_users` where vote_count=(SELECT MAX(`vote_count`) FROM `user_users` where `raceID`='4')"; $leader = mysql_query($q) or trigger_error(mysql_error()); if( $leader ){ echo($leader); } else{ echo('None'); } } ?> For Some reason this is not working right it displayes this Resource id #9 Please Help... :'( Link to comment https://forums.phpfreaks.com/topic/113892-max-count-im-stumped/ Share on other sites More sharing options...
kenrbnsn Posted July 9, 2008 Share Posted July 9, 2008 After doing a mysql_query, you have to use one of the mysql_fetch functions to actually get the data. For example: <?php if($player['raceID']==1){ $q = "select `username` from `user_users` where vote_count=(SELECT MAX(`vote_count`) FROM `user_users` where `raceID`='1')"; $leader = mysql_query($q) or trigger_error(mysql_error()); if(mysql_num_rows($leader) > 0 ){ $rw = mysql_fetch_assoc($leader); echo $rw['username']; } else{ echo 'None'; } } ?> Ken } Link to comment https://forums.phpfreaks.com/topic/113892-max-count-im-stumped/#findComment-585231 Share on other sites More sharing options...
Wolphie Posted July 9, 2008 Share Posted July 9, 2008 Please mark your other topics as solved before creating a new very similar topic. Or, just update older topics. Link to comment https://forums.phpfreaks.com/topic/113892-max-count-im-stumped/#findComment-585233 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.