473,387 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

returning autogenerated ID on new item

Lets say you have a form that when saved to the mysql database creates
a unique incremental id. The form is just the first part of a series
of things the user can do, so once the ID is created, the page would
need to know immediately what this ID is. Is there a way to grab this
ID instantly once it is created? Obviously if this were a sign-up for
and a new user name and password are involved, you can have the user
login after the initial set up and this select statement would bring
back the ID. But the situation I have doesn't work like that.

The way I have been dealing with this is simply to have a select
statement after the initial insert that requests the record based on a
couple of other fields that are likely unique. But this seems like a
rather kludgy way of doing it. Is there some other solution.

Jan 5 '07 #1
2 1440
On 5 Jan 2007 14:25:01 -0800, "toodi4" <to****@hotmail.comwrote:
>Lets say you have a form that when saved to the mysql database creates
a unique incremental id.
So, you have an auto_increment primary key?
>The form is just the first part of a series
of things the user can do, so once the ID is created, the page would
need to know immediately what this ID is. Is there a way to grab this
ID instantly once it is created?
http://php.net/results.php?q=auto_increment

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jan 5 '07 #2
mysql_insert_id()
See the manual for any pitfalls

Hendri Kurniawan

toodi4 wrote:
Lets say you have a form that when saved to the mysql database creates
a unique incremental id. The form is just the first part of a series
of things the user can do, so once the ID is created, the page would
need to know immediately what this ID is. Is there a way to grab this
ID instantly once it is created? Obviously if this were a sign-up for
and a new user name and password are involved, you can have the user
login after the initial set up and this select statement would bring
back the ID. But the situation I have doesn't work like that.

The way I have been dealing with this is simply to have a select
statement after the initial insert that requests the record based on a
couple of other fields that are likely unique. But this seems like a
rather kludgy way of doing it. Is there some other solution.
Jan 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ted Stewart | last post by:
I've got a table with an autogenerated number as it's primary key, which is being accessed by an external .NET app. When the app inserts a new record into the table, is there any way to return the...
3
by: Binny | last post by:
I have a DG with autogenerated columns. can i make a column readonly like the data key column. Thanks
8
by: Binny | last post by:
I have a DG with autogenerated columns. can i make a columns readonly like the data key column. when edititemindex is valid. Thanks
2
by: jax | last post by:
Hi All developers ! I have a datagrid which autogenerates columns by the sql SELECT list... The list (for some reasons) must be the same. So my question is HOW TO MOVE OUT A COLUMN FROM...
0
by: Luis Esteban Valencia | last post by:
Once a user clicks "add new row", a new row is created in my Datagrid. The datasource is huge so they have to scroll to the bottom of the page to edit the data in the new row. I have come across...
9
by: Steve | last post by:
How I can remove an AutoGenerated column? I wnat to inlcude the primary key in the resultset for creating some custom LinkButtons, but I don't want it (the PK) displayed in the DataGrid. I tried...
1
by: alberto | last post by:
Hi all, I have been using C# .NET for about 3 months now. I have been programming in other (Borland C++ Builder, Flash...) environments for years. I have to do a small application in WindowsCe,...
2
by: =?Utf-8?B?SnVsaWEgQg==?= | last post by:
Hi I've just moved from asp.net 1.1 to 2.0 so am new to gridviews and have a problem. I've got a gridview on a form in a web layer project. It has an objectdatasource object which calls a...
4
by: ctj951 | last post by:
I have a very specific question about a language issue that I was hoping to get an answer to. If you allocate a structure that contains an array as a local variable inside a function and return...
5
by: ctj951 | last post by:
I have a very specific question about a language issue that I was hoping to get an answer to. If you allocate a structure that contains an array as a local variable inside a function and return...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.