In the same $-POST , i wanted to perform update and delete. With the updated and deleted database, I need to select the updated data from the database. However, it tells me: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in... .I am new to sql in php, is it true that i cannot perform sql in this way? Or is there any suggestion to perform select straight after deleting and updating?
CANCEL BOOK RESERVATION
if(isset($_POST['cancelres']))
{
$query = "DELETE FROM reserved_books WHERE id='$resid';"; //delete reservation
$query .="UPDATE reserved_books SET queue = queue - 1 WHERE bookid = '$bookid' AND queue > '$bookqueue';";//update queue number where reservation that queue behind/after/ the current reservation
$query_run = mysqli_multi_query($connection, $query);
if($query_run)
{
$_SESSION['success'] = "Reservation Cancelled";
}
else
{
$_SESSION['status'] = " Reservation Not Cancelled";
}
$query= "SELECT title FROM books WHERE id = '$bookid';"; //get book title from db
$query_run = mysqli_query($connection,$query);
if(mysqli_num_rows($query_run)>0)
{
foreach ($query_run as $row) {
$title = $row['title'];
}
}
$bookres = "SELECT * FROM reserved_books WHERE bookid = '$bookid' AND queue = 1";
$bookres_run = mysqli_query($connection,$bookres);
foreach($bookres_run as $row)
{
$res_username = $row['username'];
$res_id = $row['id'];
}
$query= "SELECT option_value FROM settings WHERE option_name = 'email_temp_rescollect'"; //get email template from db
$query_run = mysqli_query($connection,$query);
if(mysqli_num_rows($query_run)>0)
{
$row = mysqli_fetch_array($query_run);
$rescollect_template = $row[0];
}}