What PHP syntax do you use to edit data in a MySQL database?

  • Thread starter Thread starter zanadoo88
  • Start date Start date
Z

zanadoo88

Guest
This is the code for the HTML form where the data is entered (through 1-5 radio buttons)

<form action="insertx4.php?id=<? echo $id; ?>&Rating=<? echo $rating; ?>&Votes=<? echo $votes; ?>" method="post"

align="center">
<img src="fail.bmp">
<input type="radio" name="radiorating" value="1">
<input type="radio" name="radiorating" value="2">
<input type="radio" name="radiorating" value="3">
<input type="radio" name="radiorating" value="4">
<input type="radio" name="radiorating" value="5">
<img src="wookie.bmp"> <br/>
<input type="submit" value="Submit"></P>
</form>

This is the important bit of insertx4.php (after I connect to the MySQL database).

$id=$_Get['id'];
$RealRating=$_Get['Rating'];
$Votes=$_Get['Votes'];
$rating=$_Post ['radiorating'];

$query="UPDATE chewytable Set Rating = '$RealRating'+'$rating' Votes='$Votes+1' WHERE 'id=$id'";
 
$query="UPDATE chewytable Set Rating = '$RealRating'+'$rating' Votes='$Votes+1' WHERE 'id=$id'";
should throw an error
because of '$RealRating'+'$rating' and no "," inbetween the fields to be updated

I would set to
$query="UPDATE chewytable Set Rating = '$RealRating + $rating', Votes='$Votes+1' WHERE 'id=$id'";
 
Back
Top