Guest User

Untitled

a guest
Oct 25th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <?php
  2. $username = "root";
  3. $password = "";
  4. $hostname = "localhost";
  5.  
  6. if(isset($_GET['id'])){
  7. $id = $_GET['id'];
  8. }else{
  9. $id = 0;
  10. }
  11. //connection to the database
  12. $dbhandle = mysql_connect($hostname, $username, $password)
  13. or die("Unable to connect to MySQL");
  14.  
  15. //select a database to work with
  16. $selected = mysql_select_db("examples",$dbhandle)
  17. or die("Could not select examples");
  18.  
  19. //execute the SQL query and return records
  20. $result = mysql_query("SELECT name FROM cars where id ='$id'");
  21.  
  22. //fetch tha data from the database
  23. while ($row = mysql_fetch_array($result)) {
  24. echo "Cars is: ".$row{'name'};
  25. }
  26. //close the connection
  27. mysql_close($dbhandle);
  28. ?>
Add Comment
Please, Sign In to add comment