Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add detailed information regarding the program in the commented areas.
- <?php
- // This creates a variable for the database
- 2. $dbname = 'cds';
- // This creates a variable for the host
- 3. $hostname = 'localhost';
- // Sets the username variable to “username”, sets the password to “secret”,
- // sets the tablename to “selections”
- 4. $username = 'username';
- 5. $password = 'secret';
- 6. $tablename="selections";
- // This connects to the hostname and uses the username and password
- //
- 7. $id_link = @mysql_connect($hostname, $username, $password);
- //
- //This connects to the dbname
- 8. $result1=mysql_listfields($dbname,$tablename);
- //This returns the field name if successful, or false if unsuccessful
- // The “0” means the first field
- 9. $name=mysql_fieldname($result1,0);
- //
- 10. $name1=mysql_fieldname($result1,1);
- //
- 11. $name2=mysql_fieldname($result1,2);
- //
- 12. $name3=mysql_fieldname($result1,3);
- //
- 13. $name4 = mysql_fieldname($result1,4);
- //
- 14. $result = mysql_db_query ("$dbname","select * from $tablename");
- //
- //
- 15. while ($row = mysql_fetch_array ($result)) {
- //
- //
- 16. print "row number: ".$row["$name"]."<br>\n";
- //
- //
- 17. print "$name1: ".$row["$name1"]."<br>\n";
- //
- //
- 18. print "$name2: ".$row["$name2"]."<br>\n";
- //
- //
- 19. print "$name3 ".$row["$name3"]."<br>\n";
- 20. print "$name4 ".$row["$name4"]."<br>\n";
- . }
- //
- 22. mysql_free_result ($result);
- 23. ?>
- 24. </body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement