Advertisement
commandrea

IF/WHILE/ELSE

Apr 25th, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <?php
  2. $db = new mysqli(" ", " ", " ", " ");
  3.  
  4. if ($db->connect_errno) {
  5. echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
  6. }
  7.  
  8. if ($stmt = $db->prepare('UPDATE volConfirm SET confirmed = "YES" WHERE email = ?')) {
  9. $stmt = $db->prepare('SELECT agreename, position, shift_times, confirmed from volConfirm WHERE email = ?');
  10. $stmt->bind_param('s', $_POST['email']);
  11. $stmt->execute();
  12. $stmt->bind_result($agreeName, $position, $shift_times, $confirmed);
  13.  
  14. while ($stmt->fetch()) {
  15. // construct your output here using $row to access database record
  16. echo "<h2>" . $agreeName . "</h2>";
  17. echo "<p> You have been assigned as a volunteer for:" . $position . "</p>";
  18. echo "<p>Your shift times are scheduled for:" . $shift_times . "</p>";
  19. echo "<p>Your shift has been confirmed:" . $confirmed . "</p>";
  20. }
  21. } else {
  22. // Notice below that the errors are still contained within the mysqli class. This means that each result will affect a single "error" property. In otherwords, if your result fails, the error returned from MySQL is assigned to the property "error".
  23. // This means the query failed
  24. echo "Email Not in System";
  25. }
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement