<HTML>
<!-- product.php - Displays a particular
product selected by the shopper -->
<head><title>The Firefox Products</title></head>
<?php
include("includes/header.php");
include("includes/connection_config.php");
?>
<br><br>
<table align = "center" border = 0 cellpadding=5 width=550>
<?php
// obtaining the id of the product
// that was selected on department_products.php
$id_product = $_REQUEST["id_prod"];
// connecting to the database on battcave.com
$link = mysql_connect($host, $user, $password);
// constructing the query string to retrieve
information about the product
$query_prod_string = "SELECT * FROM products WHERE id_product = $id_product";
$result_set = mysql_db_query($db_name, $query_prod_string, $link);
// obtaining the information on the product
while ($row = mysql_fetch_array($result_set))
{
// need to put in name, image, price
and whatever
// also need to make sure of they put the product in their
shopping basket
// we have the id_product
?>
<tr>
<td align=center colspan=2><font size=6 color="A66838"><b><i><?php
echo $row[product_name]; ?></i></b></font></td>
</tr>
<tr>
<td align=right valign=middle width=250> <img src="images_prod/<?php
echo $row[product_image]; ?>" border=0> </td>
<td align=left valign=middle><br><font size=4 color="c0c0c0"> <?php
echo $row[product_description]; ?>
<br><br>$ <?php echo $row[price]; ?> </font></td>
</tr>
<?php
} // ending loop for display of basic product
info
?>
<form method="post" action="add_item.php">
<?php
// now we need to display the attribute
category
// and attributes for the selected product if they exist
$query_attribute_category = "SELECT * FROM attribute_category JOIN
product_attribute_category ON
product_attribute_category.id_attribute_category =
attribute_category.id_attribute_category WHERE
product_attribute_category.id_product = $id_product";
// creating the resultset from the query
$result_set_attribute_category = mysql_db_query($db_name, $query_attribute_category,
$link);
// if this query returns a non-empty resultset
// we want to cycle through it to display the attribute categories
// and then the specific attributes in that category for that
product
while ($row = mysql_fetch_array($result_set_attribute_category))
{
// now we want to display the
attribute category in our table
?>
<tr>
<td align=right><font size=4 color="c0c0c0"><?php echo $row[category_name];
?>:</font></td>
<td align=left><select style="font-size: 14pt" name="sel_<?php
echo $row[category_name]; ?>">
<?php
// we also need to construct a SELECT box
// in HTML containing the appropriate attributes
// first we need to establish the current id_attribute_category
$id_attribute_category = $row[id_attribute_category];
// now we need to construct the SELECT
containing all
// the attributes associated with this product in this
attribute_category
$query_attribute = "SELECT * FROM product_attribute JOIN
attribute ON product_attribute.id_attribute =
attribute.id_attribute WHERE (product_attribute.id_product = $id_product
AND attribute.id_attribute_category = $id_attribute_category)";
// creating the resultset from the query
$result_set_attribute = mysql_db_query($db_name, $query_attribute,
$link);
// if this query returns a non-empty
resultset
// we want to cylce through it to display the attribute
categories
// and then the specific attributes in that category for that
product
while ($row_attribute = mysql_fetch_array($result_set_attribute))
{
?>
<option value="<?php echo $row_attribute[attribute_name];
?>"><?php echo $row_attribute[attribute_name]; ?></option>
<?php
} // end the loop that creates the select
for the actual attributes
?>
</select>
</td>
</tr>
<?php
} // end the loop that displays the attribute
categories
mysql_close($link);
?>
<tr>
<td align=right valign=middle><font size=4
color="c0c0c0">quantity:</font></td>
<td align=left><input type="text" size="2" name="txt_quantity"
style="font-size: 14pt" value="1">
<input type="hidden" name="id_product" value="<?php echo $id_product;
?>">
</td>
</tr>
<tr>
<td align=center colspan=2><input type="submit" value="Buy"
style="font-size: 14pt"></td>
</tr>
</form>
</table>
</BODY>
</HTML> |