Jump to content

Need help with if statement.

- - - - -

  • Please log in to reply
No replies to this topic

#1
hayschooler

hayschooler

    Learning Programmer

  • Members
  • PipPipPip
  • 31 posts
I'm trying to set up my applicated to prompt the user if they are sure they want to delete the record that was selected when they clicked the select button. If they confirm they really do want to delete the record that was chosen then they click the delete button and they get a message that the record was successfully deleted. However, as it is now, they get the message that the record was successfully deleted even before they have decided to delete the record. It then appears again when the record was deleted. How do I set up my if statement to control this behavior?

}elseif($_POST['delete']){
     $query_3 = "SELECT * from books WHERE isbn ='$_POST[isbn]'";
 
  $result_3 = mysql_query($query_3) or die ("Query 3 Failed!");
     $num_results = mysql_num_rows($result_3);
   for($i=0;$i<$num_results;$i++){
 
 $row = mysql_fetch_array($result_3);
 
  echo "<form name =\"update_form\" action\"form4.php\" method=\"post\">
   Are you sure you want to delete this record?<br /><br />
   <input type=\"text\" name=\"isbn\" value=\"$row[isbn]\">
   <input type=\"text\" name=\"author\" value=\"$row[author]\">
   <input type=\"text\" name=\"title\" size=\"50\" value=\"$row[title]\">
   <input type=\"text\" name=\"price\" value=\"$row[price]\">
   <input type=\"submit\" name=\"delete\" value=\"Delete\">
   </form><br/>";
 
   }
 
   if($query_3){
     $query_3 = "DELETE from books WHERE isbn='$_POST[isbn]'";
 
  $result_3 = mysql_query($query_3) or die ("Query 3 Failed!");
 
 
 
    }
     echo "ISBN Successfully deleted<br /><a href=\form4.php\">BACK</a>";
 
 
}elseif($_POST['select']){





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users