PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
dwfait
Forum Contributor
Posts: 113 Joined: Sun Aug 01, 2004 10:36 pm
Post
by dwfait » Mon Aug 02, 2004 1:25 pm
Hi again. How would you run a query to find the largest number in a field, and then add a new row with that number + 1. (this number is the primary key).
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Mon Aug 02, 2004 1:51 pm
Why don’t you just do an auto increment on the primary key?
dwfait
Forum Contributor
Posts: 113 Joined: Sun Aug 01, 2004 10:36 pm
Post
by dwfait » Mon Aug 02, 2004 1:51 pm
i have, but i dont know how it works lol
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Mon Aug 02, 2004 1:53 pm
dwfait
Forum Contributor
Posts: 113 Joined: Sun Aug 01, 2004 10:36 pm
Post
by dwfait » Mon Aug 02, 2004 2:04 pm
Thanks, i get it now. Also, can someone show me an example and explanation of the mysql_query("INSERT INTO") command? as i dont fully understand that...
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Mon Aug 02, 2004 2:16 pm
Code: Select all
<?
mysql_query("INSERT INTO `yourtable` SET username='john doe', email='john@doe.com'");
?>
Draco_03
Forum Regular
Posts: 577 Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada
Post
by Draco_03 » Mon Aug 02, 2004 2:34 pm
Go
here
and after you can read
this
tim
DevNet Resident
Posts: 1165 Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio
Post
by tim » Mon Aug 02, 2004 5:02 pm
phen, your command should use UPDATE TABLE
INSERT INTO table_name VALUES(" etc etc "
dwfait
Forum Contributor
Posts: 113 Joined: Sun Aug 01, 2004 10:36 pm
Post
by dwfait » Mon Aug 02, 2004 5:08 pm
but that works just fine for me...
tim
DevNet Resident
Posts: 1165 Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio
Post
by tim » Mon Aug 02, 2004 5:19 pm
lol I guess its nothing to mention, its usually that syntax is better set-thru with the UPDATE command.
Correct me if i'm wrong.