Jump to content

Retrieving Data From SQL


oliverj777

Recommended Posts

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

$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
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.