Hi, got round to trying this but having problems.
Just so that you know in the URL I am using the product name (for SEO value) but its only displaying 1 product from the cookies (also I need to find a way to only store the cookie if the product doesnt already exist in the cookie...otherwise there will be many of the same product in the cookie array as a custom could repeatedly go to the same product)
ok heres the code I have at the moment:
<?php
if ((isset($_GET['Product']) && $_GET['Product'] != "")) {
setcookie("viewedProducts", "".(isset($_COOKIE['viewedProducts'])?$_COOKIE['viewedProducts'].", ":"") ."".$_GET['Product'] ."", time()+(60*60*24*30), "/", "", 0);
}
?>
<?php
$rsProduct = new WA_MySQLi_RS("rsProduct",$ecartdb,1);
$rsProduct->setQuery("SELECT * FROM products WHERE ProductName = ?");
$rsProduct->bindParam("s", "".(isset($_GET['Product'])?$_GET['Product']:"") ."", "-1"); //colname
$rsProduct->execute();?>
<?php
$rsViewedProducts = new WA_MySQLi_RS("rsViewedProducts",$ecartdb,1);
$rsViewedProducts->setQuery("SELECT * FROM products WHERE ProductName = ?");
$rsViewedProducts->bindParam("s", "".$_COOKIE['viewedProducts'] ."", "-1"); //colname
$rsViewedProducts->execute();
?>
<?php
while(!$rsViewedProducts->atEnd()) {
?>
<a href="product.php?Product=<?php echo($rsViewedProducts->getColumnVal("ProductName")); ?>" class="b-link-fade b-animate-go">
<div class="item4"><img src="images/products/<?php echo($rsViewedProducts->getColumnVal("ProductImage")); ?>" alt="" class="responsive-image"></div>
<div class="b-wrapper">
<h2 class="b-from-left b-animate b-delay03"><?php echo($rsViewedProducts->getColumnVal("ProductName")); ?></h2>
<p class="b-from-right b-animate b-delay03">£<?php echo($rsViewedProducts->getColumnVal("ProductPrice")); ?></p>
</div>
</a>
<?php
$rsViewedProducts->moveNext();
}
$rsViewedProducts->moveFirst(); //return RS to first record
?>
NOTES: In the Edit Variable box on the MySQLi recordset if I check the box "comma-seperated list" I get a PHP error in browser.
here is th ecode it creates by selecting the checkbox (the value that changes is bindParam("sl", ..........
<?php
$rsViewedProducts = new WA_MySQLi_RS("rsViewedProducts",$ecartdb,1);
$rsViewedProducts->setQuery("SELECT * FROM products WHERE ProductName = ?");
$rsViewedProducts->bindParam("sl", "".$_COOKIE['viewedProducts'] ."", "-1"); //colname
$rsViewedProducts->execute();
?>
When you mentioned about using the IN comparison I did look that up on Google, but was unsuccessful in finding the correct way to do it..
Please help, as nearly there.
Also is this method still ok in using the Product Name in the URL since I would rather do it that way then product ID.
Chris