Advertisement
michaelyuen

Untitled

Sep 2nd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. <?php
  2.     function selected($value, $post) {
  3.         if ($value == $post) {
  4.             return "selected";
  5.         }
  6.     }
  7.    
  8.     $class= '';
  9.     if (!EMPTY($_POST['class'])) {
  10.         $class = $_POST['class'];
  11.     }
  12. ?>
  13.  
  14. <form action="" method="POST">
  15.     <select name="class">
  16.         <option value="">Please Select</option>
  17.         <option value="nursery1" <?php echo selected($nursery1, $class); ?> >Nursery One</option>
  18.         <option value="nursery2" <?php echo selected($nursery2, $class); ?> >Nursery Two</option>
  19.     </select>
  20.     <input type="button" name="class_submit" value="GO">
  21. </form>
  22. <form action="" method="POST">
  23.  
  24. <?php
  25. if (ISSET($_POST['class'])) {
  26.     $class = mysqli_real_escape_string($con, $_POST['class']);
  27.     $student_name = mysqli_query($con, "SELECT * FROM stu_tbl WHERE `class` = '.$class.'");
  28.    
  29.     // your remaining script
  30.  
  31.     // fetch your option here
  32.  
  33.     echo '<input type="hidden" name="class" value="'.$class.'">';
  34. }
  35. ?>
  36.  
  37. <input type="submit" name="submit" value="submit">
  38. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement