UPDATE ROWS FOR N NUMBER OF TIMES |
UPDATE ROWS FOR N NUMBER OF TIMES |
shankar from vizag |
Apr 30 2022, 09:18 PM
Post
#1
|
Advanced Member Group: Members Posts: 202 Joined: 18-June 13 Member No.: 19,316 |
Greetings
Earlier I posted a topic for inserting a record for n number of times and now I need help and guidance for an update query in similar way. Please suggest me how to update multiple rows for n number of times (like user specified times to repeat) I tried with this, but not working Here $days is the result of date range difference stored in a variable if(isset($days) && is_numeric($days) && $days !='' && $days>0) { for($i=1;$i<=$days;$i++) { $sql = "UPDATE availability SET cabin1='$name' where `gen_date`='$datefrm'"; if(mysqli_query($conn, $sql)){ echo "<h3>data stored in a database successfully."; } else{ echo "ERROR: Hush! Sorry $sql. " . mysqli_error($conn); } } } I have a table `availability` with columns gen_date, cabin1, cabin2, cabin3, cabin4 and this is for room reservation application. the above table should fill with name of guest as per stay days corresponding to the `gen_date` column. regards |
Lo-Fi Version | Time is now: 5th June 2024 - 02:03 PM |