Dethman Posted July 9, 2008 Share Posted July 9, 2008 Will this work? <?php function getClanMaster(){ $q = "select user_id from `user_users` where vote_count=(SELECT MAX(`vote_count`) FROM `user_users` where `raceID`='1')"; $m1 = mysql_query($q) or trigger_error(mysql_error()); $q2 = "select user_id from `user_users` where vote_count=(SELECT MAX(`vote_count`) FROM `user_users` where `raceID`='2')" $m2 = mysql_query($q2) or trigger_error(mysql_error()); $q3 = "select user_id from `user_users` where vote_count=(SELECT MAX(`vote_count`) FROM `user_users` where `raceID`='3')" $m3 = mysql_query($q3) or trigger_error(mysql_error()); $q4 = "select user_id from `user_users` where vote_count=(SELECT MAX(`vote_count`) FROM `user_users` where `raceID`='4')" $m4 = mysql_query($q4) or trigger_error(mysql_error()); $query1=("SELECT `username` FROM `user_users` WHERE `userid`='$m1'"); $query2=("SELECT `username` FROM `user_users` WHERE `userid`='$m2'"); $query3=("SELECT `username` FROM `user_users` WHERE `userid`='$m3'"); $query4=("SELECT `username` FROM `user_users` WHERE `userid`='$m4'"); $master1=Mysql_query($query1); $master2=Mysql_query($query2); $master3=Mysql_query($query3); $master4=Mysql_query($query4); if( $master1 > 0 ){ $leader1=$master1; } if( $master2 > 0 ){ $leader2=$master2; } if( $master3 > 0 ){ $leader3=$master3; } if( $master4 > 0 ){ $leader4=$master4; } else{ $leader4=1; } else{ $leader3=1; } else{ $leader2=1; } else{ $leader1=1; } } ?> Thanks For the critique, Brian Flores AKA Dethman... Quote Link to comment Share on other sites More sharing options...
Wolphie Posted July 9, 2008 Share Posted July 9, 2008 Why not just select the username in the same query? :S And also, it's mysql_query() not Mysql_query() P.S. could you mark your other topic as solved before creating another related question. Quote Link to comment Share on other sites More sharing options...
trq Posted July 9, 2008 Share Posted July 9, 2008 Will this work? That all depends on what it is exactly you want it to do, however, you have failed to describe your problem. Quote Link to comment Share on other sites More sharing options...
trq Posted July 9, 2008 Share Posted July 9, 2008 And also, it's mysql_query() not Mysql_query() Functions are not case sensitive in php. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted July 9, 2008 Share Posted July 9, 2008 You're doing all this work in a function, but you're not returning anything, so it will all be lost when you exit the function. What are you trying to do? Ken Quote Link to comment 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.