Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How do I insert MySQL row properly?
Old 04-28-2008, 02:16 PM How do I insert MySQL row properly?
andyp's Avatar
Extreme Talker

Posts: 165
Name: andy patterson
Trades: 0
I've noticed that when I add a row it doesnt increment the id field properly. I first noticed this when I deleted rows then tried to add rows, the added rows id would increment from the highest id of a deleted row.

So how would I increment an id column from the last row thats in the table?.
__________________
My webmaster news & tips blogs with free scripts and tutorials -
Please login or register to view this content. Registration is FREE
andyp is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-28-2008, 02:29 PM Re: How do I insert MySQL row properly?
Extreme Talker

Posts: 177
Trades: 0
As long as the Id column is auto_increment, when you do your insert statement, it should look something like this:

PHP Code:
mysql_query("INSERT INTO users (username, firstName, lastName) VALUES ('kbailey', 'Kyle', 'Bailey')"); 
just make sure you specify which columns you want teh information to be added to where username, firstname, lastname is, and the values correspond to those tables in that order, and that will increment the Id field automatically.
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 04-28-2008, 10:46 PM Re: How do I insert MySQL row properly?
addonchat's Avatar
Super Talker

Posts: 115
Name: Chris Duerr
Trades: 0
Here's a quick example/reference for using AUTO_INCREMENT:

http://dev.mysql.com/doc/refman/5.0/...increment.html
__________________
Chris Duerr
AddonChat Java Chat Software

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
addonchat is offline
Reply With Quote
View Public Profile
 
Old 04-29-2008, 12:52 PM Re: How do I insert MySQL row properly?
andyp's Avatar
Extreme Talker

Posts: 165
Name: andy patterson
Trades: 0
Thanks
__________________
My webmaster news & tips blogs with free scripts and tutorials -
Please login or register to view this content. Registration is FREE
andyp is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How do I insert MySQL row properly?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.61940 seconds with 12 queries