Hey, I am new to PHP and need a little help. Whilst constructing my own cms i have become stuck. The code below is to pull up the title of each product in the table and to display them. Also making the results as links to then go onto reading all the infor about each product .i.e price, description etc..... All the code is contained within the one php file, yet when i go through to read all the details on each product it only comes up with the title. Any ideas for a dumb monkey. Thanx
<?php
include '../includes/sessions.php';
?>
<?php
include '../includes/config.php';
include '../includes/opendb.php';
// if no id is specified, list the available articles
if(!isset($GET['productid']))
{
$self = $SERVER['PHP_SELF'];
$query = "SELECT productid, title FROM products ORDER BY productid";
$result = mysql_query($query) or die('Error : ' . mysql_error());
// create the article list
$content = '<ol>';
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
list($productid, $title) = $row;
$content .= "<li><a href=\"$self?productid=$productid\">$title</a></li>\r\n";
}
$content .= '</ol>';
$title = 'Available Products';
} else {
// get the article info from database
$query = "SELECT title, price, category, size, description, weight FROM products WHERE productid =" . $_GET['productid'];
$result = mysql_query($query) or die('Error : ' . mysql_error());
$row = mysql_fetch_array($result, MYSQL_BOTH);
$title = $row['title'];
$content = $row['content' . 'description'];
}
include '../includes/closedb.php';
?>
<html>
<head>
<title>
<?php echo $title; ?>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
h1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
color: #006699;
font-weight: bold;
}
.main {
padding: 10px;
border: 1px solid #006699;
position: relative;
width: 580px;
margin-top: 20px;
margin-bottom: 20px;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</head>
<body>
<table width="600" border="0" align="center" cellpadding="10" cellspacing="1" bgcolor="#336699">
<tr>
<td bgcolor="#FFFFFF">
<h1 align="center"><?php echo $title; ?></h1>
<?php
echo $content;
// when displaying an article show a link
// to see the article list
if(isset($_GET['productid']))
{
?>
<?php
?>
<p> </p>
<p align="left"><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Products List</a></p>
<?php
}
?>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF">
<?php
echo "<a href='../mainadmin.php'>Main Menu</a>";
?>
</td>
</tr>
</table>
</body>
</html>
Thanks again for any help.