Hello ~ I am adding a "Related Products" section at bottom of my product page. Below works fine but wondering if there is a better way to do this.
I am using MySQL (not MySQLi) with "includes"
2nd query uses duplicate fields but fewer than the 1st query plus added an add'l field (f13), and WHERE is different.
<?php
//select items from db
$items = mysql_query ("SELECT f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12 FROM tableOne WHERE myproductNo='x000'") or die(mysql_error());
while($item = mysql_fetch_array($items))
{
?>
MAIN PRODUCT STUFF
<?php
}
?>
RELATED PRODUCTS below
<?php
//select items from db
$items = mysql_query ("SELECT f2, f3, f4 FROM tableOne WHERE status='live' AND f13-which-is-not-included-in-query-above='category1' ORDER BY dbNo ASC LIMIT 0,4") or die(mysql_error());
//extract every item
while($item = mysql_fetch_array($items))
{
?>
4 related products
<?php
}
?>
Thank you ~