Using the update command, I want to change the type_name
for a specific entry in the database, but it is changing the type_name
for all the entries with the same type_id
.
I need it to only change that individual entry's type_name
, and not the type_name
that is associated with all the entries with the same type_id
.
I have an update query:
$sql = 'UPDATE photos
LEFT JOIN types
ON photos.type_id = types.type_id
SET photos.photo_title = $_POST['photo_title'],
types.type_name = $_POST['type_name']
WHERE photos.photo_id = 3';
Here's the form I'm using:
<form name="form1" method="post" action="">
<input name="photo_title" type="text" value=""/>
<textarea name="type_name"></textarea>
<input type="submit" name="update" value="Update entry" />
</form>
Here's my database structure:
TABLE photos
photo_id PRIMARY KEY
photo_title
type_id FOREIGN KEY
TABLE types
type_id PRIMARY KEY
type_name