Jump to content

E-commerce and PHP


s_ainley87

Recommended Posts

Hello Everyone,

 

I am currently trying to make a product catalog and it is not going very well, this is my attempt at the code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Browse Products</title>
<?
require_once('include/mysql_connect.php');
?>
</head>

<body>
<?

// Are we looking at a particular artist?
if (isset($_GET['cid'])) {
$aid = (int) $_GET['cid'];
if ($aid > 0) {
	$query = "SELECT artists.category_id, product_name, product_price, produst_desc, product_id FROM category, product WHERE category.cateogory_id = product.category_id AND product.category_id =$cid ORDER BY product.product_name";
} else {
	$query = "SELECT category.category_id, product_name, product_price, product_desc, product_id FROM category, products WHERE category.category_id = product.category_id ORDER BY category.category_name ASC, product.product_name ASC";
}
} else {
$query = "SELECT category.category_id, product_name, product_price, product_desc, product_id FROM category, products WHERE category.category_id = product.category_id ORDER BY category.category_name ASC, products.products_name ASC";
}

// Create the table head.
echo '<table border="0" width="90%" cellspacing="3" cellpadding="3" align="center">
<tr>
<td align="left" width="20%"><b>Category</b></td>
<td align="left" width="20%"><b>Product Name</b></td>
<td align="left" width="40%"><b>Description</b></td>
<td align="right" width="20%"><b>Price</b></td>
</tr>';

// Display all the prints, linked to URLs.
$result = mysqli_query ($dbc, $query);
while ($row = mysqli_fetch_array ($result) {

// Display each record.
echo "	<tr>
	<td align=\"left\"><a href='browse_prints.php?cid={$row['category_id']}'>{$row['category_name']}</a></td>
	<td align=\"left\"><a href=\"view_print.php?pid={$row['product_id']}\">{$row['product_name']}</td>
	<td align=\"left\">{$row['product_desc']}</td>
	<td align=\"right\">\${$row['product_price']}</td>
</tr>\n";

} // End of while loop.

echo '</table>'; // Close the table.

mysqli_close($dbc); // Close the database connection.

?>
</body>
</html>

At the moment the page shows all the queries and no product, it is also show the links as the $row[whatever] rather than a product name etc.  Any ideas on what is wrong with it, or can some point me in the direction of a tutorial that is easy to follow?

Link to comment
https://forums.phpfreaks.com/topic/96146-e-commerce-and-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.