Forums
This topic is locked
get data from specific record
Posted 10 Apr 2002 11:46:43
1
has voted
10 Apr 2002 11:46:43 Tim Steinbrock posted:
Hi,i have an insert record form on which are (besides some other fields to enter) two choices: Set Parent_ID to the ID this record will recieve (via auto-incement), or set Parent_ID to a different record that has been selected via List-Box.
How can i find out what the ID of this record after insertion will be, i guess something like LastRecord(res_id)++ ??
Till
p.s. although the labeling is in german you might check it out at
www.handlanger.de/avid/resourcen2.php3 and then click on "resource hinzufuegen" (which means "add resource". Well and the form that pops up then is broken, it's just to illustrate what i mean, the part with parent_id = etc..
Edited by - tilllt on 10 Apr 2002 11:50:50
Edited by - tilllt on 10 Apr 2002 11:51:17
Replies
Replied 11 Apr 2002 17:51:55
11 Apr 2002 17:51:55 Eric Kaiser replied:
If I'm understanding you correctly, you want to get the last auto imcremented number? If so, in PHP4 all you gotta do is apply this code after the insert:
$id = mysql_insert_id();
$id = mysql_insert_id();
Replied 13 Apr 2002 02:06:25
13 Apr 2002 02:06:25 Tim Green replied:
Assuming of course that you are using MySQL as your database server.
The most reliable way of doing this is to use:-
$id = $connection->Insert_ID();
Where $connection is the name of your created connection. This will work with all databases that ADODB supports, and is the most reliable method.
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
The most reliable way of doing this is to use:-
$id = $connection->Insert_ID();
Where $connection is the name of your created connection. This will work with all databases that ADODB supports, and is the most reliable method.
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>