Reputation: 95
found an easier way around it
<html>
<form method="post" name="update" action="edit.php" />
Alliance Name :
<input type="text" name="term" />
Diplomacy :
<select name="dip">
<option value="">Neutral</option>
<option value="Hostile">Hostile</option>
<option value="pending">Pending</option>
<option value="friendly">Friendly</option>
<option value="">Neutral</option>
</select>
<input type="submit" name="Submit" value="update" />
</form>
</html>
and
connection
$term = $_POST['term'];
$dip = $_POST['dip'];
$query = "UPDATE my_table SET dip = '$dip' WHERE alliance = '$term'";
if(mysql_query($query)){
echo "updated";}
else{
echo "fail";}
?>
all works great, thanks for all your advice.
I'm slowly getting there. you are all a great help and i respect you greatly
Upvotes: 0
Views: 41
Reputation: 48887
the only thing it will not do is actually add the data to the database
That's because your sql:
UPDATE mordred13 SET dip='$dip' WHERE dip='$dip'
doesn't actually change anything (it's like saying "set the color of everything that's blue to blue"). If you're trying to update columns that are NULL
(gleaned from your comments), you can do:
UPDATE mordred13 SET dip='$dip' WHERE dip IS NULL
A couple of important asides, your code is vulnerable to SQL injection and mysql_*
functions are deprecated. Look into using an API that supports parameterized queries, such as mysqli or PDO.
Upvotes: 2