Basically Im passing a variable over by a form and then showing my table on a page based on that variable. So the sql looks something like: SELECT * FROM CONCERT ORDER BY Concert.Seat ASC LIMIT $input_value So this page will show the rows based on the variable I have passed over. So If i entered 4 and the value of the variable was then 4 I would see 4 seats available (4 rows in the database). Now How would I update this into the database using an update form? Any help appreciated.
okay, since you have fetched them, you just have to loop through the rows and then update using each unique id
Something like that UPDATE CONCERT set seat = $somevalue WHERE id = $id where somevalue comes from a form. Its really hard to give you a solution, since we don't know the fields in the database or how you are using them, but generally, you could print out the id in a form with a checkbox and update the ids in the database where the checkbox is selected.
Something like this... Hope this helps: $dbc = mysqli_connect("localhost", "root", "", "database"); $query = "SELECT * FROM concert ORDER BY concet.seat ASC LIMIT $input_value"; $result = mysqli_query($dbc, $query) or die('Error Querying database '.mysqli_error($dbc)); while($rows = mysqli_fetch_array($result)) { $id = $rows['id']; $new_query = "UPDATE concet SET concert.seat='$some_value' WHERE id=$id"; $new_result = mysqli_query($dbc, $new_query) or die('Error Querying database '.mysqli_error($dbc)); //And you are done now! echo "Successfully updated table row with id=$id"; } PHP: obviously the variable $some_value has to come from some form or get!