Here is the script:
Code: Select all
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head><title> Jims Bargain Basement DVD'S </title></head>
<CENTER><H1>Catalouge</H1><BR></CENTER>
<CENTER><H2>In alphabetical order</H2></CENTER>
<?php
//include details for logging onto mysql database
include 'mysql.php';
//include error function
include 'error.php';
//Setup query for execution
$result = mysql_query ("SELECT d.title, di.dir_name, p.prod_name, d.duration, d.dvd_desc, g.genre_name , d.price FROM dvd d, director di, producer p, genre g WHERE d.dirid = di.dirid AND d.prodid = p.prodid AND d.genre = g.genreid", $connection);
//connect to mysql with some error handling
if (!($connection = @ mysql_connect($host, $user, $passwd)))
die("Could not connect to the database");
//select my database with some error handling
if(!mysql_select_db($dbName, $connection))
showerror();
//Run the query through the connection to mysql with some error handling
if(!($result = @ mysql_query($result,$connection)))
showerror();
echo"<br><table border = "0\ ">";
//List all DVDs using data obtained from $result in an HTML format table
while($row = @ mysql_fetch_array($result))
{
//format dvd title as a heading
echo"<br><tr><br><td bgcolor = "#6699FF">" .
$row["title"] . " " .
"</tr></td><br>"
//Format review, director name, producer name and genre as a body of text
echo "<br> <tr> <br> \t <td bgcolor="#CCFFFF">" . " " .
"<b>Review: </b>" .
$row["dvd_desc"] . " " .
"<b>Director: </b>" .
$row["dir_name"] . " " .
"<b>Producer: </b>" .
$row["prod_name"] . " " .
"<b>Genre: </b>" .
$row["genre_name"] . " " .
"</td></tr><br>";
//format a row for the price
echo "<br> <tr> <br> \t <td bgcolor="#33FF99">" .
"<b>Price: £" .
$row["price"] . " " .
"</td></tr>";
//for presentation
echo "<br><tr><br>\t<td></td><br></tr>";
}
echo "<br> </table> <br>";
//close the connection to mysql with some error handling
if(! mysql_close($connection))
showerror();
?>
<CENTER><A HREF="index.php">Home -</A><A HREF="/~bj253/catalouge.php"> Catalouge -</A><A HREF=""> Search -</A><A HREF=""> Basket -</A><A HREF=""> Checkout</A></CENTER>
</body>
</html>Jimbo