The record is still not updating. Here is my form (updatecourseentry.php)
<?php
$user = "root";
$host = "localhost";
$password = "";
$connection = mysql_connect($host, $root, $password) or die ("Couldn't connect to server.");
$database = "courses";
$db = mysql_select_db($database) or die ("Couldn't select database.");
$sql = "SELECT coursename FROM trainingtopics";
$result = mysql_query($sql) or die(mysql_error());
echo $result."=result<br>";
while($row=mysql_fetch_array($result))
{
echo "<option value='".$row['coursecode']."'>".$row['coursename']."</option>\n";
}
?>
</select>
><br>
<br>
<input type='text' name='accreditingbody' value='accreditingbody'>
<br>
<br>
<textarea name="briefdesc" cols="75" id="briefdesc"></textarea>
<br>
<br>
<textarea name="aimedat" cols="75" id="aimedat"></textarea>
<br>
<br>
<select name="level1" size="1" id="level1">
<option>Yes</option>
<option>No</option>
<option>Not selected</option>
</select>
<br>
<br>
<select name="level2" size="1" id="level2">
<option>Yes</option>
<option>No</option>
<option>Not selected</option>
</select>
<br>
<br>
<select name="level3" size="1" id="select2">
<option>Yes</option>
<option>No</option>
<option>Not selected</option>
</select>
<br>
<br>
<select name="elearning" size="1" id="select3">
<option>Yes</option>
<option>No</option>
<option>Not selected</option>
</select>
<br>
<br>
<select name="facetoface" size="1" id="select4">
<option>Yes</option>
<option>No</option>
<option>Not selected</option>
</select>
<br>
<br>
<select name="blended" size="1" id="select5">
<option>Yes</option>
<option>No</option>
<option>Not selected</option>
</select>
<br>
<br>
<input name="elearningtime" type="text" id="elearningtime" value="" size="50">
<br>
<br>
<input name="facetofacetime" type="text" id="facetofacetime" value="" size="50">
<br>
<br>
<input name="blendedtime" type="text" id="elearningtime" value="" size="50">
<br>
<br>
<input type="submit" name="Submit" value="Update">
<input type="reset" name="reset" value="Reset">
</form>
<br>
<br>
<br>
<br>
<br>
</div>
</form>
and here is the formhandler that is supposed to take the selected coursename from the dropdown box in updatecourseentry.php as well as anything inputted into the form and update the record:
<?php
$user = "root";
$host = "localhost";
$password = "";
$connection = @mysql_connect($host, $root, $password)
or die ("Couldn't connect to server.");
$database = "courses";
$db = @mysql_select_db($database, $connection)
or die ("Couldn't select database.");
if (isset($_POST['Submit'])) {
//insert the values entered into the courseentry form into the database
$coursename = $POST['coursename'];
$accreditingbody = $POST['accreditingbody'];
$briefdesc = $POST['briefdesc'];
$aimedat = $POST['aimedat'];
$level1 = $POST['level1'];
$level2 = $POST['level2'];
$level3 = $POST['level3'];
$elearning = $POST['elearning'];
$facetoface = $POST['facetoface'];
$blended = $POST['blended'];
$elearningtime = $POST['elearningtime'];
$facetofacetime = $POST['facetofacetime'];
$blendedtime = $_POST['blendedtime'];
$sql = "UPDATE trainingtopics SET
coursename = '$coursename',
accreditingbody ='$accreditingbody',
briefdesc = '$briefdesc',
aimedat = '$aimedat',
level1 = '$level1',
level2 = '$level2',
level3 = '$level3',
elearning = '$elearning',
facetoface = '$facetoface',
blendedlearning = '$blended',
elearntime = '$elearningtime',
facetime = '$facetofacetime',
blendedtime = '$blendedtime'
WHERE coursename = '$coursename'";
or die (mysql_error().'<hr /><pre>'.$sql.'</pre>');
//execute query and store the result
$res = mysql_query($sql,$connection);
//check to make sure the query actually ran
if(!$res) {
echo mysql_error("Update successful").":".mysql_error()."";
return 0;
//$result = $db->query($sql);
echo $sql;
}
}
?>