close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

creating a wish list for ecommerce

Thread began 3/12/2015 11:02 am by Christopher West | Last modified 1/18/2016 2:19 pm by Christopher West | 4634 views | 5 replies

Christopher WestCommunity Expert

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:
<?php

if ((isset($_GET['Product']) && $_GET['Product'] != "")) {
    
setcookie("viewedProducts""".(isset($_COOKIE['viewedProducts'])?$_COOKIE['viewedProducts'].", ":"")  ."".$_GET['Product']  .""time()+(60*60*24*30), "/"""0);
}
?>



php:
<?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:
<?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:
<?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:
<?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

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...