Jump to content

Database return id from input


TylerRLD

Recommended Posts

I currently have a php set up for a high-scores list. The mysql database has 3 fields. 1-id 2-Name 3-Score

 

id is set to auto increment

 

ive got it working to properly input name and score into the database and it automatically gives the entry an "id"...

heres the code:

 

 

$dbc = mysql_connect('ZShiscoreapp.db.10895904.hostedresource.com','username','password');
if (!$dbc) {
die('Not Connected :' .mysql_error());
}
$db_selected = mysql_select_db("ZShiscoreapp", $dbc);
if (!$db_selected)
{
die("Cant Connect : " .mysql_error);
}
 
 
 
$pname=$_GET['nameinput'];
$pscore=$_GET['scoreinput'];
$query="INSERT INTO highs SET Score='$pscore', Name='$pname' ";
$result=mysql_query($query);

 

 

I want to get the assigned "id" from the database and print it. how can i do this?

Link to comment
https://forums.phpfreaks.com/topic/277170-database-return-id-from-input/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.