Page 1 of 1

Php mysql select and insert problem

Posted: Thu Jun 18, 2009 7:15 am
by surya.n.j
Hi every one i have a registration application, where the user details are maintained in two tables, iam generating a auto increment value for userid and inserting it in the table when i click on subimt. Now i want to select the user id after the insert statement is executed to place some fields in another table at the submission time. I cannot get the id value even i wrote next to insert statement and i even tried by closing mysql connection after insert and again connecting for select it does notwork if anyone has solution please give me solution

Re: Php mysql select and insert problem

Posted: Thu Jun 18, 2009 12:22 pm
by icesolid

Code: Select all

<?php
$result = mysql_query("SELECT `userid` FROM `table_name` ORDER BY `userid` DESC");
$row = mysql_fetch_array($result);
 
// Print the newest userid in the database
 
echo $row['userid'];
?>