|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
I just write a record to my sql database, how can i get current (last)record number any help would be appreaciate.
|
|
#2
|
|||
|
|||
|
Are you talking about the id generated by an auto_increment field??
If so you can use last_insert_id |
|
#3
|
|||
|
|||
|
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by rod k:
Are you talking about the id generated by an auto_increment field?? If so you can use last_insert_id[/quote] Yes, that's exactly what I am talking about,I am trying do like this array_unshift($arrlink, "<a href="http://www.xxxx.com/display.php?id="$last_insert_id"" target="_blank">$title</a><br>n"); but something wrong with it,what I want is to make URL like http://www.xxx.com/display.php?id=163 in text file for each line,could you help again. thanks a lot for help |
|
#4
|
|||
|
|||
|
OK, I couldn't be more specific since I didn't know what scripting language you were using.
In PHP, after you run your insert you can grab the last insert id like this: $link=mysql_pconnect(foo,bar,foobar); mysql_db_select(whatever); $result=mysql_query("insert into table ..."); $id=mysql_insert_id($link); |
|
#5
|
|||
|
|||
|
First, You are realy nice,I feel so lucky can get your help,you just told me what I am looking for.
I use PHP, before you second time answer my question, I try to use $query2 = "select id from content where title = '$title'"; $result2 = MYSQL_QUERY($query2); $row2 = mysql_fetch_array($result2); $id=$row2[0]; but your way just what I am looking for, I can only use last line $id=mysql_insert_id($link); to replace above three line I used in my script. thanks a lot, all the best to you |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > how to get current record number? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|