Page 1 of 1
Newbie MySQL Question
Posted: Fri Jun 14, 2002 10:13 am
by cyk0
Hello,
I know this is probably an easy question, but I don't know how to do it.
I have 4 columns; name, email, code, ip. I have one form to add rows with just the code column filled and the others left blank. How do I make another form to update those rows to add the rest (name, email, ip)?
Any ideas?
Thanks in advance.
Posted: Fri Jun 14, 2002 12:43 pm
by twigletmac
You want to do an
UPDATE query. Something like,
Code: Select all
$sql = "UPDATE table SET name='$name', email='$email', ip='$ip' WHERE code='$code'";
Where $name, $email, $ip and $code have all been passed from the second form and table is the name of the table you want to update. $sql is then the query that you would run.
Mac
Posted: Fri Jun 14, 2002 12:56 pm
by cyk0
Thanks for that.
I have another question (sorry). Now that I know how to update rows, I want to know how to update the next row each time someone successfully signs up for a code, so each person gets a different code. Would I have to make an ID column and set it to auto_increment or something?
Posted: Fri Jun 14, 2002 2:47 pm
by twigletmac
What does the code need to look like? Can it just be a number because then you could use an auto-increment on the code column and make the code the primary key so it will also be unique for each person.
Mac
Posted: Fri Jun 14, 2002 3:36 pm
by cyk0
The codes are a mixture of numbers and letters, so I don't know if that would work.
I set an id column to auto_increment so it does 0, 1, 2, etc. But I don't know how to do the code.
Thanks for any help you can give