NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Auto numbering in MySQL?

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
5 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 12-29-2005, 06:44 PM THREAD STARTER               #1 (permalink)
NamePros Regular
 
3GN Media's Avatar
Join Date: Jan 2005
Posts: 439
3GN Media is just really nice3GN Media is just really nice3GN Media is just really nice3GN Media is just really nice
 



Auto numbering in MySQL?


Hey guys, I read a tutorial a long time ago on how to automatically have mysql number the rows but I forgot. Anyway, take a look at this for me:
????: NamePros.com http://www.namepros.com/programming/152408-auto-numbering-in-mysql.html

Code:
$query = "INSERT INTO `games` VALUES (94, $cat, '$flash.swf', '$title', 0, 1, '$img.jpg', '400', '300', '$description', 24, '')";
Instead of putting 94 and changing it to 95, 96, etc. How can I make it so that it does automatically instead of having to manually change the number in the tables?
3GN Media is offline  
Old 12-29-2005, 06:53 PM   #2 (permalink)
NamePros Regular
 
nick's Avatar
Join Date: Jun 2004
Location: Iowa City
Posts: 703
nick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud of
 


Save The Children
"auto_increment" in phpmyadmin
__________________
formally ninedogger
------
Want to talk to a stranger? -->| Click Here | TalkToAStranger.com | <-- Meet New Friends
nick is offline  
Old 12-29-2005, 06:56 PM THREAD STARTER               #3 (permalink)
NamePros Regular
 
3GN Media's Avatar
Join Date: Jan 2005
Posts: 439
3GN Media is just really nice3GN Media is just really nice3GN Media is just really nice3GN Media is just really nice
 



So do I just leave it blank in the query?
3GN Media is offline  
Old 12-29-2005, 07:05 PM   #4 (permalink)
Eating Pie
 
iNod's Avatar
Join Date: Nov 2004
Location: Canada
Posts: 2,267
iNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud of
 


Special Olympics AIDS/HIV Cystic Fibrosis Save The Children Baby Health Cystic Fibrosis
In PHPMyAdmin select auto_increments for Extras and change the mysql query to

PHP Code:
$query "INSERT INTO `games` VALUES ($cat, '$flash.swf', '$title', 0, 1, '$img.jpg', '400', '300', '$description', 24, '')"
????: NamePros.com http://www.namepros.com/showthread.php?t=152408
Remove the 94 it will auto generate it.

iNod.
__________________
I feel old.
iNod is offline  
Old 12-29-2005, 07:06 PM THREAD STARTER               #5 (permalink)
NamePros Regular
 
3GN Media's Avatar
Join Date: Jan 2005
Posts: 439
3GN Media is just really nice3GN Media is just really nice3GN Media is just really nice3GN Media is just really nice
 



Thanks for the help guys
3GN Media is offline  
Old 01-03-2006, 02:18 PM   #6 (permalink)
NamePros Member
Join Date: Oct 2005
Posts: 173
brianmn is on a distinguished road
 



So will this work if I have in a table records 1, 2, 3, 4 and then i delete 2 will the next record added continue onto 5 then or will it be 4 giving me two 4's and causing a possible conflict
brianmn is offline  
Old 01-03-2006, 05:53 PM   #7 (permalink)
NamePros Member
Join Date: Nov 2005
Posts: 123
cytech will become famous soon enough
 



Hey,

It will give you 5

MySQL keeps tracks off the records.
__________________
CYTechnologies - Professional Website Development and Design

GetCustomerRated.com - Get Customer Rated allows a business to capture genuine word of mouth advertising and place it in a virtual player on their website.
cytech is offline  
Old 01-03-2006, 05:54 PM   #8 (permalink)
NamePros Regular
 
Rudy's Avatar
Join Date: Jul 2005
Location: United States
Posts: 586
Rudy is just really niceRudy is just really niceRudy is just really niceRudy is just really nice
 


Save a Life
Another good and helpful tool is MySQL Control Center, that you can download.
__________________
Smooth Stone Services
Affordable Web Hosting Solutions Starting at only $4.95/month, IT Consulting and Technical Support


Hunt Sources - Hunting Resources Online
Rudy is offline  
Old 01-04-2006, 06:16 AM   #9 (permalink)
NamePros Regular
 
tansks's Avatar
Join Date: Dec 2004
Location: Penang, Malaysia
Posts: 886
tansks is just really nicetansks is just really nicetansks is just really nicetansks is just really nicetansks is just really nicetansks is just really nicetansks is just really nicetansks is just really nice
 



Is that possible to get the auto increment value after insert the record?
__________________
Hostegic - Premium cPanel Hosting [Softaculous | RvSitebuilder | R1Soft daily backups | LiteSpeed]
[UK] [Linux - cPanel | Windows - WebsitePanel/Plesk] [Shared Hosting | Reseller Hosting | VPS]
tansks is offline  
Old 01-04-2006, 06:33 AM   #10 (permalink)
NamePros Regular
 
Palyriot's Avatar
Join Date: Jul 2004
Location: Seattle, Wa
Posts: 596
Palyriot is a jewel in the roughPalyriot is a jewel in the roughPalyriot is a jewel in the rough
 



I was gonna say just count the total rows, then make the total rows the file id. Or, simple order by ID, then add 1 to the last row. Perfect way of doing it, but I guess that is easier.
Palyriot is offline  
Old 01-04-2006, 07:03 AM   #11 (permalink)
NamePros Regular
 
moondog's Avatar
Join Date: Jun 2004
Posts: 563
moondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to all
 



Originally Posted by tansks
Is that possible to get the auto increment value after insert the record?

If you are coding in PHP, you can use the mysql_insert_id() function.

-Bob
__________________
Want a way to monitor your website against hacking? Check out CrossCheck.net
moondog is offline  
Old 01-04-2006, 09:32 AM   #12 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,074
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
Originally Posted by iNod
In PHPMyAdmin select auto_increments for Extras and change the mysql query to

PHP Code:
$query "INSERT INTO `games` VALUES ($cat, '$flash.swf', '$title', 0, 1, '$img.jpg', '400', '300', '$description', 24, '')"
????: NamePros.com http://www.namepros.com/showthread.php?t=152408
Remove the 94 it will auto generate it.

iNod.
That wont work as sql will think that $cat is the first field. You can either have it so you explicitly name the table fields such as

PHP Code:
$query "INSERT INTO `games` ('field1', 'field2', 'field3', 'field4', 'field5', 'field6', 'field7', 'field8', 'field9', 'field10')VALUES ($cat, '$flash.swf', '$title', 0, 1, '$img.jpg', '400', '300', '$description', 24, '')"
obviously changing the field names to their proper names or you can make it

PHP Code:
$query "INSERT INTO `games` VALUES ('', $cat, '$flash.swf', '$title', 0, 1, '$img.jpg', '400', '300', '$description', 24, '')"
????: NamePros.com http://www.namepros.com/showthread.php?t=152408
__________________
Manage your portfolio using my new Domain Portfolio Management script.
Securing Your Domain Name From Theft
Peter is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Great Scripts for Sale With Resale Rights! Zeeble Scripts For Sale 20 01-04-2006 01:39 AM
Auto Body Shops Database - 114,270 Records odditysoftware Content For Sale 0 11-30-2005 10:54 PM
Tutorial: How to Install Apache2 MySQL and PHP on Windows deadserious Webmaster Tutorials 35 09-21-2005 09:46 PM
HOW TO: Use shell to control MySQL. abdulmueid Webmaster Tutorials 16 08-27-2005 08:17 AM
Tutorial: Getting Started With MySQL (The Basics) deadserious Webmaster Tutorials 3 04-18-2004 01:17 PM

 
All times are GMT -7. The time now is 02:05 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger