Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.54 KB | None | 0 0
  1. Add detailed information regarding the program in the commented areas.
  2. <?php
  3. // This creates a variable for the database
  4. 2.      $dbname = 'cds';
  5. // This creates a variable for the host
  6. 3.      $hostname = 'localhost';
  7. //  Sets the username variable to “username”, sets the password to “secret”,
  8. // sets the tablename to “selections”
  9. 4.      $username = 'username';
  10. 5.      $password = 'secret';
  11. 6.      $tablename="selections";
  12. // This connects to the hostname and uses the username and password
  13. //
  14.  
  15. 7.      $id_link = @mysql_connect($hostname, $username, $password);
  16. //
  17. //This connects to the dbname
  18. 8.      $result1=mysql_listfields($dbname,$tablename);
  19.  //This returns the field name if successful, or false if unsuccessful
  20. // The “0” means the first field
  21. 9.      $name=mysql_fieldname($result1,0);
  22. //
  23. 10.  $name1=mysql_fieldname($result1,1);
  24. //
  25. 11.  $name2=mysql_fieldname($result1,2);
  26. //
  27. 12.  $name3=mysql_fieldname($result1,3);
  28. //
  29.  
  30. 13.  $name4 = mysql_fieldname($result1,4);
  31. //
  32.  
  33. 14.  $result = mysql_db_query ("$dbname","select * from $tablename");
  34.  
  35. //
  36. //
  37.  
  38. 15.  while ($row = mysql_fetch_array ($result)) {
  39. //
  40. //
  41. 16.  print "row number: ".$row["$name"]."<br>\n";
  42. //
  43. //
  44. 17.  print "$name1: ".$row["$name1"]."<br>\n";
  45. //
  46. //
  47. 18.  print "$name2: ".$row["$name2"]."<br>\n";
  48. //
  49. //
  50. 19.  print "$name3 ".$row["$name3"]."<br>\n";
  51. 20.  print "$name4 ".$row["$name4"]."<br>\n";
  52. .  }
  53. //
  54.  
  55. 22.  mysql_free_result ($result);
  56.  
  57. 23.  ?>
  58. 24.  </body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement