OK, I'm confused how to write an INSERT/UPDATE for this simple app I'm developing locally to learn more about db interactions.
I have an "edit" page, which is populated from the db and lists up to 9 user links (user_id 2 in this case), so something like:
<input type="text" name="link1" value="www.yahoo.com">
<input type="text" name="link2" value="www.google.com">
<input type="text" name="link3" value="www.amazon.com">
<input type="text" name="link4" value="">
<input type="text" name="link5" value="">
<input type="text" name="link6" value="">
<input type="text" name="link7" value="">
<input type="text" name="link8" value="">
<input type="text" name="link9" value="">
<input type="submit" name="submitted" value="update">
There should be 9 text inputs showing up here, the first 3 inputs populated with urls from the links table below...Those inputs don't seem to be showing up in my question even though they do in my preview.
My links table is just 2 columns and looks like:
user_id linkurl
1 http://www.abcnews.com
2 http://www.yahoo.com
2 http://www.google.com
2 http://www.amazon.com
3 http://www.ebay.com
3 http://www.craigslist.org
How do I go about writing an INSERT/UPDATE query for, say, editing the 3rd link and adding a 4th, possibly a 5th, 6th, 7th, 8th and 9th?
I also have on this same page a section for the user's personal info and I can update that easily with a query like:
$query = "UPDATE users
SET first_name='$firstname', last_name='$lastname', email='$email', state='$state'"
if($newpass1){
$query .= ", pass=md5('$newpass1')";
}
$query .= " WHERE user_id = {$_SESSION['user_id']}";