Just somewhere to keep my notes while I'm playing.

Thursday, June 4, 2009

Listing Data

Here is the code for my Publishers list:


<?php
echo "<html><head><title>List Menu</title></head>";
echo "<body>";
echo "<h1>Explore My CD Collection</h1>";
echo "<ol>\n";
$con = mysql_connect("localhost","timj","xxxxxxx");
if (!$con) {
die('Could not connect: ' . mysql_error());
}

mysql_select_db("cddb", $con);

$result = mysql_query("SELECT itemtext, itemlink, itemno FROM menus WHERE name = 'listmenu' order by itemno");
while ($row = mysql_fetch_array($result)) {
echo "<li>\n";
echo "<a href=\"" . $row['itemlink'] . "\">";
echo $row['itemtext'] . "</a>";
echo "\n</li>\n";
}
mysql_free_result($result);
mysql_close($con);
echo "</ol>";
echo "</body>";
echo "</html>";
?>


The Output html looks like this:

D:\Database\CDDB\DocRoot>php publishers.php
<html><head><title>Publsihers</title></head><body><h1>Publishers in my CD Collection</h1><ol>
<li>
EMI</li>
<li>
SONY</li>
</ol></body></html>
D:\Database\CDDB\DocRoot>

No comments: