oliverj777 Posted June 11, 2011 Share Posted June 11, 2011 Hello, Its been a while since I've done a bit of PHP - and I have literally forgotten everything. Okay, so I have this variable that holds a 'players name': $CurrentPlayer = $_POST["PHPcurrentPlayer"]; And all I want to do, it check against my SQL to find any matches that are the same to PHPcurrentPlayer in the row of "player". So basically, if(CurrentPlayer == SQL player), once it has found the row, I want it to pull a out a 'score' data from the player. Hope that makes sense? No? I have a table in SQL called 'highscore' - which has fields of: player and score. I want to check CurrentPlayer against the highscore[player] and retrieve [score] in a variable. I really need help. Thanks Link to comment https://forums.phpfreaks.com/topic/239103-retrieving-data-from-sql/ Share on other sites More sharing options...
fugix Posted June 11, 2011 Share Posted June 11, 2011 $query = mysql_query("SELECT * FROM highscore WHERE player = '$CurrentPlayer'") or die(mysql_error()); while($row = mysql_fetch_assoc($query)) { $score = $row['score']; // do whatever you'd like from here } hope this helps Link to comment https://forums.phpfreaks.com/topic/239103-retrieving-data-from-sql/#findComment-1228505 Share on other sites More sharing options...
oliverj777 Posted June 11, 2011 Author Share Posted June 11, 2011 Works like a charm, thanks! Link to comment https://forums.phpfreaks.com/topic/239103-retrieving-data-from-sql/#findComment-1228511 Share on other sites More sharing options...
fugix Posted June 11, 2011 Share Posted June 11, 2011 Works like a charm, thanks! no problem, glad i could help Link to comment https://forums.phpfreaks.com/topic/239103-retrieving-data-from-sql/#findComment-1228519 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.