I'm trying to update my table when I've finished editing a certain post. I'm trying to update it with the id that is pasted through.
For some reason my query isn't getting the id to update. Here is what I currently have.
Displaying the data from the database using the id that is passed through:
if (isset($_GET['id']) && is_numeric($_GET['id'])){
$id = $_GET['id'];
$show = mysql_query("SELECT * FROM notes WHERE '$id' = id");
while($edit_row = mysql_fetch_assoc($show)){
echo '
<tr>
<td align="center">Title</td>
<td><input type="text" name="title" value="'.$edit_row['title'].'" class="title"></td>
</tr>
<tr>
<td align="center">Note</td>
<td><textarea cols="35" rows="6" name="notes" class="notes">'.$edit_row['note'].'</textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" value="Update" class="new"></td>
</tr>
';
}
}
Here is my query update:
if(isset($_POST['submit'])){
$title = trim(mysql_real_escape_string($_POST['title']));
$notes = trim(mysql_real_escape_string($_POST['notes']));
$update = mysql_query("UPDATE notes SET title = '$title' WHERE id = '$id'") or die(mysql_error());
header("Location:notes.php");
}
Is there anything wrong? Is the update query not getting the id somehow?