Jump to content

MAX Count im Stumped....


Dethman

Recommended Posts

<?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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.