Jump to content


Photo

row ID number


  • Please log in to reply
3 replies to this topic

#1 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 11 March 2006 - 06:56 PM

Dear all

I have a php insert query to insert some form data. Once the form has been submitted and the data added to the sql database, is there anyway to bring the auto increase ID number which is generated in the sql database?

Any help would be great.

Thanks

Ed

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 11 March 2006 - 07:20 PM

[a href=\"http://ca.php.net/manual/en/function.mysql-insert-id.php\" target=\"_blank\"]http://ca.php.net/manual/en/function.mysql-insert-id.php[/a] will retrieve the last autoincrement ID
Legend has it that reading the manual never killed anyone.
My site

#3 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 11 March 2006 - 07:48 PM

Hi

That worked great, thanks.

Can the value be passed to another page via a session? How would that be done? Tried few things without any luck.

Thanks in advance

Ed

#4 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 11 March 2006 - 08:02 PM

Worked it out, if anyone is interested I passed

$_SESSION['nextid'] = mysql_insert_id();

with my php page action and then called the session name ($_SESSION['nextid']) on the next page.

Thanks anyone who helped

Ed




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users