Jump to content
MakeWebGames

Can't get username from table.


PHPDevil
 Share

Recommended Posts

Hi again.

Just having a mysqli issue. First time using databases and tables.

I have a table with PlayerIDs and Username as the title. Table itself is called users

When a person logs in i create a session variable for ID

 

	$_SESSION['ID'] = $id;

 

Now in the game I want to retrieve that username so I'm able to display it. I don't want to use the session variable to do this as i will be reusing that username constantly so i would want it stored in a variable.

 

$data = mysqli_query($mysqli, "SELECT * FROM userss WHERE PlayerIDs =" . $_SESSION['ID']); 
$info = mysqli_fetch_array( $data ); 

 

The above is my sql that im using. And to ouput the result I use

 

echo $info['Username'];

 

Yet nothing gets displayed.

Is there a way where I can call all this data easily and display it easily. Like for example if i wanted to display there level aswell. So in other words control what is displayed?

Thanks

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

 Share

×
×
  • Create New...