Advertisement
dzeikob

Untitled

Jun 5th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. $servername = "localhost";
  5. $username = "root";
  6. $password = "123";
  7. $dbname = "Soidud";
  8.  
  9. //Create connection
  10. $conn = new mysqli($servername, $username, $password, $dbname);
  11.  
  12. // Check connection
  13. if ($conn->connect_error) {
  14. die("Connection failed: " . $conn->connect_error);
  15. }
  16.  
  17. $userName = htmlspecialchars($_POST["userName"]);
  18. $userName = "Jakob";
  19. if ($userName == "") {
  20. die;
  21. }
  22.  
  23. $sql = "SELECT Cars.CarMark, Cars.CarYear
  24. FROM Cars, Users
  25. WHERE 'Jakob'=Users.Name And Users.UserID=Cars.UserID;";
  26.  
  27. $result = $conn->query($sql);
  28.  
  29. if ($result->num_rows > 0) {
  30. // output data of each row
  31. while($row = $result->fetch_assoc()) {
  32. echo "carMark: " . $row["CarMark"]. "<br>";
  33. }
  34. } else {
  35. echo "0 results";
  36. }
  37.  
  38. echo "finished";
  39.  
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement