Jump to content

help!! adding products to session cart!


ryans_85

Recommended Posts

Hi all, I have a problem with passing information through the code below to add to the shopping cart.  The script works perfectly well when my SQL command to grab the products is simply "SELECT * FROM tblProducts". When i add "WHERE cat_id = '" . $cat_id ."' then nothing gets passed to the cart. All that happens is the printed out "You did not select any items to buy.".

 

Thanks Guys if you could help me it would be fantastic.

 

if ($_REQUEST["navigate"]=="proceed"){

/** We need the user to have selected at least one item, so let's see what they've chosen **

  *** by looping through the submitted Quantity fields **/

  $strCart="";

$num2 = $num;

for ($iLoop=5; $iLoop <= $num2; $iLoop++) {

  $strThisQuantity=$_REQUEST["Quantity" . $iLoop];

  if ($strThisQuantity == "") $num2++;

  else

  if ($strThisQuantity>0)

  $strCart=$strCart . $strThisQuantity . ",";

}

 

  if (strlen($strCart)==0){

      // Nothing was selected, so simply redesiplay the page with an error

      $strPageError="You did not select any items to buy. ";

      $_SESSION["strCart"]="";

  }

 

  else  {

      // Save the cart to the session object

      $_SESSION["strCart"]=$strCart;

      // Proceed to the view shopping basket screen

      ob_end_flush();

      redirect("viewBasket.php");

  }

}

 

Link to comment
https://forums.phpfreaks.com/topic/181381-help-adding-products-to-session-cart/
Share on other sites

mysql is

 

$cat_id = $_GET["cat_id"];

$query = "SELECT * FROM tblProducts WHERE cat_id='".$cat_id."'";

$rsPrimary = mysql_query($query)

or die ("Query '$query' failed with error message: \"" . mysql_error () . '"');

$num=mysql_numrows($rsPrimary);

mysql_close();

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.