Advertisement
Guest User

result.php

a guest
Oct 12th, 2012
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <html>
  2. <?php
  3. echo "<h2>Lista Autori</h2>";
  4. echo "<table border='1' style='border-collapse: collapse;border-color: silver;'>";
  5. echo "<tr style='font-weight: bold;'>";
  6. echo "<td width='auto' >&nbsp;Autore</td>";
  7. echo "<td width='auto' >&nbsp;Titolo</td>";
  8. echo "</tr>";
  9. //1. Connessione al Database
  10. $connection = mysql_connect("localhost","root","");
  11. if(!$connection){
  12. die("Database connection failed: " . mysql_error());
  13. }
  14. //2. Seleziona Database
  15. $db_select = mysql_select_db("forms1",$connection);
  16. if (!$db_select) {
  17. die("Database connection failed: " . mysql_error());
  18. }
  19. //3. Interroga Database
  20.  
  21. $result = mysql_query("SELECT * FROM demo ORDER BY Autore, Titolo", $connection);
  22.  
  23. if (!$result) {
  24. die("Database query failed: " . mysql_error());
  25. }
  26.  
  27. //4. Use Returned Data
  28. while ($row = mysql_fetch_array($result))
  29. {
  30.  
  31. echo "<tr>";
  32. echo "<td width='auto'>" . "&nbsp;" . $row[1] . "&nbsp;" . "</td>";
  33. echo "<td width='auto'>" . "&nbsp;" . $row[2] . "&nbsp;" . "</td>";
  34. echo "</tr>";
  35.  
  36. }
  37.  
  38. mysql_close($connection);
  39. ?>
  40. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement