MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old August 3rd, 2000, 02:33 PM
newbie1229 newbie1229 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: sydeny nsw aus
Posts: 53 newbie1229 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
I just write a record to my sql database, how can i get current (last)record number any help would be appreaciate.

Reply With Quote
  #2  
Old August 3rd, 2000, 05:05 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
Are you talking about the id generated by an auto_increment field??

If so you can use last_insert_id

Reply With Quote
  #3  
Old August 3rd, 2000, 10:10 PM
newbie1229 newbie1229 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: sydeny nsw aus
Posts: 53 newbie1229 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
<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


Reply With Quote
  #4  
Old August 3rd, 2000, 11:24 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
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);

Reply With Quote
  #5  
Old August 4th, 2000, 02:41 AM
newbie1229 newbie1229 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: sydeny nsw aus
Posts: 53 newbie1229 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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



Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > how to get current record number?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway