Output from "My Library"\n"; // Connecting to MySQL using the username "zxyx999" and the password "12345" // IF YOU MODIFY THE USERNAME AND PASSWORD FOR DEBUGGING PURPOSES, BE SURE // TO SET IT BACK TO THESE VALUES BEFORE YOU SUBMIT IT. $connection = mysql_connect ("localhost", "zxyx999", "12345"); // Using the database "zxyx999". IF YOU MODIFY THE DATABASE FOR DEBUGGING // PURPOSES, BE SURE TO SET IT BACK TO THIS VALUE BEFORE YOU SUBMIT IT. mysql_select_db("zxyx999", $connection); //// Make Array of Genre Types (This method might also work for status!) //// // From the table genres, grab the fields ID and GENRE_DESC. From these // records, we will make an array of genre descriptions called $genres. // By the way, there is a way you can use a relational search to do this // with the query alone and not using this ugly second query. $genre_query = mysql_query("select ID, GENRE_DESC from genres", $connection); $genres = array(); while($genre_record = mysql_fetch_array($genre_query, MYSQL_ASSOC)) $genres[$genre_record[ID]] = $genre_record[GENRE_DESC]; // From the table library, grab the fields TITLE, AUTHOR, PUB_YR, and GENRE // for all of the records. The received records should be sorted on the // field TITLE $result = mysql_query("select TITLE, AUTHOR, PUB_YR, GENRE from mylibrary order by PUB_YR", $connection); // Start the table in HTML and print the column headings print "\n"; print "\n"; print "\n\n\n\n\n"; print "\n"; $i=0; // Print the individual records, each as a row in the table while(($record = mysql_fetch_array($result, MYSQL_ASSOC)) && ($i < $_GET['limit'])) { $i++; $bgcolor_str = "#99cc99"; if(($i&1)==0) $bgcolor_str = "#ffffff"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } // Close the table tag print "
ItemTitleAuthorPublication YearGenre
"; print $i; print ""; print $record[TITLE]; print ""; print $record[AUTHOR]; print ""; print $record[PUB_YR]; print ""; print $genres[$record[GENRE]]; print "
\n"; // Close the connection to MySQL mysql_close ($connection); ?>