I have a simple form, and a MySQL table set up.
All I am trying to do is every time the form is submitted add 1 onto the selected row amount.
Table is as simple as:
answer | amount
------------------------
Yes | 5
No | 12
Maybe | 1
And the form is:
<form action="submit.php" method="post">
Is this a cool pie chart?:
<input type="radio" name="group1" value="Yes"> Yes<br>
<input type="radio" name="group1" value="No"> No<br>
<input type="radio" name="group1" value="Maybe"> Maybe<br>
<input type="submit">
</form>
Then in submit.php I have the following so far, but doesn't seem to be working
<?php
$sql = "UPDATE results SET amount= amount + 1 where answer = ?";
$stmt = mysqli_prepare($conn, $sql);
mysqli_stmt_bind_param($stmt, "s", $selected_option);
if (isset($_POST['submit'])) {
$selected_option = $_POST['group1'];
if ($selected_option == 'Yes') {
mysqli_stmt_execute($stmt);
}else if ($selected_option == 'No') {
mysqli_stmt_execute($stmt);
} else if ($selected_option == 'Maybe')
mysqli_stmt_execute($stmt);
}
?>
So if someone answers yes the amount row for yes will increase to 6 etc etc.
I have managed to call the data and even add it into the Google Visualization API using tutorials, but seem to failing at this part.
Thanks in advance everyone.
submit.phpcode?