Advertisement
Guest User

Untitled

a guest
Mar 30th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. +----+------+-------+-----------+-----------+
  2. | id | name | state | xcoord | ycoord |
  3. +----+------+-------+-----------+-----------+
  4. | 1 | lake | CA | 36.746585 | 22.234564 |
  5. | 2 | pond | TX | 26.123123 | 12.456789 |
  6. +----+------+-------+-----------+-----------+
  7.  
  8. "; ?>
  9. ID Name State X Coord Y Coord
  10. {$row['id'] {$row["name"] {$row["state"]} {$row["xcoord"]} {$row["ycoord"]}
  11.  
  12. <?php
  13. /*
  14. * db.inc.php
  15. * These are the DBMS credentials and the database name
  16. */
  17. $hostName = "xxxx";
  18. $databaseName = "yyyy";
  19. $username = "zzzz";
  20. $password = "wwww";
  21. // Show an error and stop the script
  22. function showerror()
  23. {
  24. if (mysql_error())
  25. die("Error " . mysql_errno() . " : " . mysql_error());
  26. else
  27. die ("Could not connect to the DBMS");
  28. }
  29. ?>
  30.  
  31. <html>
  32. <head>
  33. <title>Locations</title>
  34. </head>
  35. <body>
  36. <table border=1>
  37. <tr>
  38. <th>ID</th>
  39. <th>Name</th>
  40. <th>State</th>
  41. <th>X Coord</th>
  42. <th>Y Coord</th>
  43. </tr>
  44.  
  45. <?php
  46.  
  47. include 'db.inc.php';
  48.  
  49. // Connect to MySQL DBMS
  50. if (!($connection = @ mysql_connect($hostName, $username, $password)))
  51. showerror();
  52.  
  53. // Use the location database
  54. if (!mysql_select_db($databaseName, $connection))
  55. showerror();
  56.  
  57. // Create SQL statement
  58. $query = "SELECT * FROM locations"; // the table name is "locations"
  59.  
  60. // Execute SQL statement
  61. if (!($result = @ mysql_query ($query, $connection)))
  62. showerror();
  63.  
  64. // Display results *** My inclination is that something is awry with the following echo
  65. while ($row = @ mysql_fetch_array($result))
  66. echo "<tr>
  67. <td>{$row['id']</td>
  68. <td>{$row["name"]</td>
  69. <td>{$row["state"]}</td>
  70. <td>{$row["xcoord"]}</td>
  71. <td>{$row["ycoord"]}</td>
  72. </tr>";
  73. ?>
  74.  
  75. </table>
  76. </body>
  77. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement