Klance Posted April 14, 2008 Share Posted April 14, 2008 I want to display the highest score of a song from the db GHScores the table GH80 and the field Score. The field Score holds all the scores, how do I just pull out just the highest score? Quote Link to comment Share on other sites More sharing options...
discomatt Posted April 14, 2008 Share Posted April 14, 2008 ORDER BY `score` DESC LIMIT 1 Quote Link to comment Share on other sites More sharing options...
effigy Posted April 14, 2008 Share Posted April 14, 2008 SELECT MAX(field) FROM table Quote Link to comment Share on other sites More sharing options...
unidox Posted April 14, 2008 Share Posted April 14, 2008 SELECT MAX(field) FROM table That will work. Quote Link to comment Share on other sites More sharing options...
Klance Posted April 14, 2008 Author Share Posted April 14, 2008 Ok, I tried that and it came out with "Resource id #2" Heres the code I used: <?php $host = "localhost"; $user = "root"; $pass = "****"; $db = "GHScores"; $conn = mysql_connect($host, $user, $pass) or die("Unable to connect!") ; mysql_select_db($db) or die("Unable to select database!"); $query = "SELECT MAX(score) FROM GH80"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); echo $result ?> Quote Link to comment Share on other sites More sharing options...
discomatt Posted April 14, 2008 Share Posted April 14, 2008 <?php $host = "localhost"; $user = "root"; $pass = "****"; $db = "GHScores"; $conn = mysql_connect($host, $user, $pass) or die("Unable to connect!") ; mysql_select_db($db) or die("Unable to select database!"); $query = "SELECT MAX(score) FROM GH80"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); echo mysql_result($result, 0); ?> Quote Link to comment Share on other sites More sharing options...
Klance Posted April 14, 2008 Author Share Posted April 14, 2008 <?php $host = "localhost"; $user = "root"; $pass = "****"; $db = "GHScores"; $conn = mysql_connect($host, $user, $pass) or die("Unable to connect!") ; mysql_select_db($db) or die("Unable to select database!"); $query = "SELECT MAX(score) FROM GH80"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); echo mysql_result($result, 0); ?> Thank you 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.