Hi Everyone,
I am really stuck as to how to do this. Take a look at this page:
http://www.freemanholland.com/hanging/product-range/
You can see a list of “Wines” going a long way down the page. Columns are Style, Name, Cost & Country.
Now this is displayed with the following SQL query:
public function selectProductCategoriesByID($ID){
$sql = "SELECT * FROM tbl_product_categories WHERE ID = $ID";
$result = mysql_query($sql);
return $result;
}
And the $ID is retrieved via the URL ($_GET)…
Now what i need to do is GROUP the reults by the “Style” column. In my database i have the following:
ID, style, name, cost, country, date_added, catID, deleted
Each set of wines below to a specific catID, so its fairly simple. But if you look at the page the list goes on and on so i need to group these like so:
Aromatic, Aromatic Magnum, Blended, Chardonnay and so on…
The way i want this to be displayed is as such:
<h2>Aromatic</h2>
//List of wines
<br/>
<h2>Aromatic Magnum</h2>
//List of wines
<br/>
<h2>Blended</h2>
//List of wines
So how can i accomplish this? On the page i display the results i have this code:
<?
$products = Products::selectAllProductsByCatID($_GET['catID']);
$i=0;
while($row = mysql_fetch_array($products)){
echo "<tr class=\\"row$i\\"><td class='tdrow'>$row[style]</td><td class='tdrow'>$row[name]</td><td class='tdrow'>£$row[cost]</td><td class='tdrow'>$row[country]</td>";
$i++;
$i = $i % 2;
}
?>
How can i change this to show the wines how i want? Can someone please help?
Thanks again