Advertisement
Guest User

Undefined Variable Before Submit IS USE

a guest
Sep 10th, 2019
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $database = "abc";
  6.  
  7. $dblink = mysqli_connect($servername,$username,$password,$database);
  8.  
  9. if(isset($_POST['submit'])) {
  10. if($_POST['select']=='all_records') {
  11. $query = "SELECT Kod_Dorm
  12. FROM dorm
  13. ";
  14. }
  15. elseif($_POST['select']=='A302') {
  16. $query = "SELECT Kod_Dorm
  17. FROM dorm
  18. WHERE Kod_Dorm = 'A302'";
  19. }
  20. elseif($_POST['select']=='A303') {
  21. $query = "SELECT Kod_Dorm
  22. FROM dorm
  23. WHERE Kod_Dorm = 'A303'";
  24. }
  25.  
  26. $results = mysqli_query($dblink, $query) or die (mysqli_error());
  27. }
  28.  
  29. echo "<table>"; // start a table tag in the HTML
  30.  
  31. while($row = mysqli_fetch_array($results)){ //Creates a loop to loop through results
  32. echo "<tr><td>".$row['Kod_Dorm']."</td></tr>"; //$row['index'] the index here is a field name
  33. }
  34.  
  35. echo "</table>"; //Close the table in HTML
  36.  
  37. ?>
  38.  
  39. <form class="filteroption" action="" method="post">
  40. <select class="select" name="select">
  41. <option value ="all_records" selected="selected">All records</option>
  42. <option value ="A302" >A302</option>
  43. <option value ="A303" >A303</option>
  44. </select>
  45. <input class="" type="submit" name="submit" value="submit">
  46. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement