Jump to content

CarolHCX

New Members
  • Posts

    2
  • Joined

  • Last visited

CarolHCX's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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]; }}
  2. //multi query $sql= "SELECT option_value FROM settings WHERE option_name = 'email_temp_issue';"; //1 $sql .="SELECT title FROM books WHERE id = '$bookid';"; //2 $sql .="SELECT fullName from students WHERE email = '$username'"; //3 $sql_run = mysqli_multi_query($connection,$sql); if(mysqli_num_rows($sql_run)>0) { foreach ($sql_run as $row) { $email_template = $row['option_value']; //retrieve from query 1 $title = $row['title']; //retrieve from query 2 $name = $row['fullName']; //retrieve from query 3 } } I am trying to store the data from the multi query into each variable, which I am not sure how to do..Anyone can help? :)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.