Advertisement
Guest User

Untitled

a guest
May 30th, 2018
96
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. //if nothing entered in the form, the user is redirected back to the form
  3.  
  4. if(empty($_GET['fname'])){
  5. header ("Location: index.html");
  6. exit;
  7. }
  8. ?>
  9.  
  10. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  11. <head>
  12. <title>Search Results</title>
  13. <style type="text/css">
  14. body, h2, tr { text-align: center }
  15. </style>
  16. </head>
  17. <body>
  18. <?php
  19. $servername = "localhost";
  20. $username = "root";
  21. $password = "";
  22. $dbname = "students";
  23. // Create connection
  24. $conn = new mysqli($servername, $username, $password, $dbname);
  25.  
  26. ?> <h2> Vie vnesovte : </h2><h2>"<?php echo $_GET["fname"]; ?> "</h2><br>
  27.  
  28. <h2> Studenti so ime kako vnesenoto: </h2> <br>
  29. <?php
  30. $fname = $_GET["fname"];
  31. $sql = "SELECT * FROM student WHERE firstname like '%$fname%'";
  32. $result = $conn->query($sql);
  33. $brojac=1;
  34. if ($result->num_rows > 0) {
  35. // output data of each row
  36. while($row = $result->fetch_assoc()) {
  37. echo "".$brojac.". ID: " .$row["sid"]. " | Ime i Prezime: " . $row["firstname"]. " " . $row["lastname"]. " | Adresa: ". $row["address"] . " | Telefon: " . $row["telephone"]." | Data na ragjanje: ".$row["dob"]."<br>";
  38. $brojac=$brojac+1;
  39. }
  40. } else {
  41. ?><h2>Imeto koe go vnesovte ne postoi vo databazata!</h2> <?php
  42. }
  43. $conn->close(); ?>
  44. <br/><a href="index.html"><< Back to Search</a>
  45. </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement