EDIT: I've gotten it to update, but just not the records I want. The value of watson (found via ex.php?teacher=watson) isn't pulling through into the update and thus only values with nothing in the teacher field are being updated. //end edit
I have been looking at this for hours now and thought I would ask for some help, if you don't mind. This is a prototype (so it's sufficing for now) for teachers to select an Announcement image on their own website, where they just select an image and it updates right into the db field and displays on their page. Now the problem I'm having is that it won't update. When I run the echo of my sql update, I get that teacher=$teacher where the $teacher is supposed to be replace with the teachers name that is in the url. ie ex.php?teacher=watson, it's not pulling the 'watson' out. This is probably something stupid I'm doing on my part, but after hours of looking at it, I'm so frustrated and was hoping that one of you wonderful people could help me.
Thanks!
<?php
if ($submit) {
// process form
$DBhost = "localhost";
$DBuser = "dbuser";
$DBpass = "dbpass";
$DBName = "dbname";
$db = mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
mysql_select_db("dbname",$db);
$sql = "UPDATE images SET image='$image' WHERE teacher='$teacher'";
$result = mysql_query($sql);
echo "Record Updated.\n";
} else{
// display form
?>
My form element:
<form name="selection" method="post" action="<?php echo $PHP_SELF?>">
Announcements<p><input type="hidden" name="category" value="announcements">
<input value="a001.gif" type="radio" name="image"><img src="image.gif" width="109" height="73" alt="" border="0" align="center">
| <input value="a002.gif" type="radio" name="image"><img src="image.gif" width="109" height="73" alt="" border="0" align="center">
| <input value="a003.gif" type="radio" name="image"><img src="image.gif" width="109" height="73" alt="" border="0" align="center">
<p>
<input value="a004.gif" type="radio" name="image"><img src="image.gif" width="109" height="73" alt="" border="0" align="center">
| <input value="a005.gif" type="radio" name="image"><img src="image.gif" width="109" height="73" alt="" border="0" align="center">
| <input value="a006.gif" type="radio" name="image"><img src="image.gif" width="109" height="73" alt="" border="0" align="center">
<p><input type="hidden" name="teacher" value="$teacher">
<input type="submit" value="Submit" name="submit">
</form>
<?php
} // end if
?>