SHARE
TWEET

Untitled

a guest Dec 6th, 2016 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $dbname = "contactsDB";
  6.  
  7. $cat = $_GET['cat'];
  8.  
  9. // Create connection
  10. $conn = new mysqli($servername, $username, $password, $dbname);
  11. // Check connection
  12. if ($conn->connect_error) {
  13.     die("Connection failed: " . $conn->connect_error);
  14. }
  15. if($cat){
  16.     $sql = "SELECT * FROM contactsTbl where cat='$cat'";
  17. }
  18. else{
  19.     $sql = "SELECT * FROM contactsTbl";
  20. }
  21. $result = $conn->query($sql);
  22. echo "<H1>Your Results Master...</h1>";
  23. if ($result->num_rows > 0) {
  24.     // output data of each row
  25.     while($row = $result->fetch_assoc()) {
  26.         echo $row['id'].", ".$row['fname'].", ".$row['sname']."<br/>";
  27.     }
  28. } else {
  29.     echo "0 results";
  30. }
  31. $conn->close();
  32. ?>
  33. <a href="all.php">All Records</a>
  34. <a href="all.php?cat=work">Work Records</a>
  35. <a href="all.php?cat=personal">Personal Records</a>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top