I have a table (January) in my database with the following fields:
name (primary)
tour1
tour2
tour3
The purpose of this table is to allow players of an online golf tour to select the competitions
they want to enter that particular month.
Problem:
When I use "INSERT" everything works fine but, no matter how much I try; "UPDATE" won't work (it doesn't write anything)
and I don't have any error message that explains why. I can update all the fields myself using PHPMyAdmin but my PHP form
just won't.
I'm a beginner ( as you will certainly notice in the code below).
<?php
$db = mysql_connect("xxx", "xxx","xxx");
mysql_select_db("xxxx",$db);
if ($submit) {
$sql="SELECT * FROM January ";
$result=mysql_query($sql,$db);
$row = mysql_fetch_array($result);
$name = $row["name"];
$sql = "UPDATE January SET tour1 = '$tour1', tour2 = '$tour2', tour3 = '$tour3' WHERE name='$name' ORDER BY name ASC LIMIT 1";
$result = mysql_query($sql) or die(mysql_error());
echo "Your record has been updated!";
else {
// display form
?>
<form name="Form_update" method="post" action="<?php echo $PHP_SELF?>">
<table width="60%" cellpadding="1" cellspacing="1" id="entrants">
<tr>
<td>Name</td>
<td><select name="name">
<option selected="selected">Select player...
</option>
<option value=""><?=$row['name']?>xxx</option>
<option value=""><?=$row['name']?>xxx</option>
<option value=""><?=$row['name']?>xxx</option>
<option value=""><?=$row['name']?>xxx</option>
</select></td>
</tr>
<tr>
<td>Tour</td>
<td>Champ:
<input type="checkbox" name="tour1" value=""> |
Pro:
<input type="checkbox" name="tour2" value=""> | Amateur: <input type="checkbox" name="tour3" value=""> </td>
</tr>
<tr><td>Submit:</td>
<td>
<input type="Submit" name="submit" value="Enter information">
</td>
</tr>
</table>
</form>
<?php
} // end if
?>