I have a form which users fill out and the information is then put into a database when the user hits submit. Each entry in the database has a primary key (obviously) that is set up by the database. However, I need to be able to tell the user what their number is when they submit the form becuase this becomes their reference number. Here is my code:
$hostname = "myhost.com"; // The host server.
$username = "myName"; // The username you created for this database.
$password = "Mypass"; // The password you created for the username.
$usertable = "MyTable"; // The name of the table you made.
$dbName = "myDB"; // This is the name of the database you made.
MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable");
@mysql_select_db( "$dbName") or die( "Unable to select database");
$sqlquery = "INSERT INTO MyTable
(
a, b, c, d
)
VALUES
(
'$value_a', '$value_b', '$value_c', '$value_d'
)";
$results = mysql_query($sqlquery);
mysql_close();
So now how do I get the primary key value for this query? $results only returns a true or false value.
Any suggestions are much apprechiated! Thanks.