Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

How do I find the ID of a new row added to a table?

This is a discussion on How do I find the ID of a new row added to a table? within the PHP forums, part of the Web Development category; Hello all, How do I find the ID of a new row added to a table?...

Go Back   Geeks Talk > Web Development > PHP
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

PHP PHP - The most popular scripting language. Discuss PHP related questions here. Sample Scripts, Popular downloads, tools and utilites and more...

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-16-2009
Junior Member
 
Join Date: Aug 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
shreya. is on a distinguished road
How do I find the ID of a new row added to a table?

Hello all, How do I find the ID of a new row added to a table?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-17-2009
Expert Member
 
Join Date: May 2009
Location: Bangalore
Posts: 991
Thanks: 155
Thanked 420 Times in 201 Posts
rijus is just really nicerijus is just really nicerijus is just really nicerijus is just really nicerijus is just really nice
Re: How do I find the ID of a new row added to a table?

Hi,


Here's the script.

<?php
$q = mysql_query("INSERT INTO mytable VALUES('test')");
$rownumber = mysql_insert_id();
//$rownumber contains the id of the new row
?>


Regards,
Riju.
Reply With Quote
  #3 (permalink)  
Old 08-17-2009
Junior Member
 
Join Date: Aug 2009
Location: Pakistan
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
sajjad_1 is on a distinguished road
Re: How do I find the ID of a new row added to a table?

Quote:
Originally Posted by shreya. View Post
Hello all, How do I find the ID of a new row added to a table?
hi,
here is another method if you id is auto incremented then.

$sql="select max(id) from table ";
Reply With Quote
  #4 (permalink)  
Old 08-26-2009
Junior Member
 
Join Date: Aug 2009
Location: GUNTUR
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
pradeepboyapati13 is on a distinguished road
Talking Re: How do I find the ID of a new row added to a table?


Actually I too got same doubt,But tell u later..........
Reply With Quote
Reply

  Geeks Talk > Web Development > PHP

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Query to find structure of a table Geek_Guest SQL 16 07-07-2009 04:35 AM
How to find Table Size timmy Oracle 2 09-23-2008 04:52 AM
How to find a max number in a row of a table. ganesh.b SQL 1 07-25-2008 08:01 AM
How can I find the name of the function for a particular table Geek_Guest Oracle Apps 0 06-22-2007 03:05 AM
How to find Defined key fields in a table? sharifhere SQL 2 02-22-2007 01:01 AM


All times are GMT -4. The time now is 01:26 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved