I have a site that has categories of images generated from the database, I am trying make it so when the user selects a category, the query is based off of that selection and the respective images load. Is that something that can be done?
Here is my current code.
$dynamiclist is all of the images that are in that category
$listcategories is what I'd like to have determine the query
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php
include "storescripts/connect_to_mysql.php";
$dynamicList = "";
$linkquery = "*";
$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 10");
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$product_name = $row["product_name"];
$price = $row["price"];
$subcategory = $row["subcategory"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
$dynamicList .=
'
<div>
<li>
<a href="product.php?id=' . $id . '"><img style="border:#FFF 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="180" height="255" border="1" /></a>
<h4> <a name= ' . $id . ' id= ' . $id . ' value= ' . $id . ' href="product.php?id= ' . $id . '"> ' . $product_name . ' </a> </h4>
<p>'. $subcategory .'</p>
<span> $' . $price . '</span>
</li>
</div>
';
}
} else {
$dynamicList = "An error has occurred, call a mortician.";
}
?>
<!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">
<body>
<?php include ("../header.php");?>
<?php include ("../menu.php");?>
<div class="body">
<div class="sidebar">
<div class="first">
<h2><a href="#">Dora Designs</a></h2>
<!-- Dynamic Categories -->
<ul>
<?
include "storescripts/connect_to_mysql.php";
$data = mysql_query("SELECT category, id FROM products GROUP BY category") or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
$listcategory = $info["category"];
print
'<li>
<a name=" " value="" id="" href=""> ' . $listcategory . ' </a>
</li>';
}
mysql_close();
?>
</ul>
</div>
<div>
<h2><a href="#">Weddings</a></h2>
</div>
<div>
<h2><a href="#">Birthdays</a></h2>
</div>
</div>
<div class="content">
<div class="figure">
<img src="/images/galleryholder.png" alt=""/>
</div>
<div class="products">
<div class="paging">
<div class="first">
<h2>Gallery</h2>
</div>
</div>
<ul>
<?php echo $dynamicList; ?>
</ul>
</div>
</div>
Thank you very much.