Posted: Sun Jul 16, 2006 11:01 am Post subject: سبد خرید
سلام اميدوارم امتحاناتتون رو با موفقيت گذرونده باشين
آقاي آقا محمدي من به كمك فوري و فوتي احتياج دارم مساله مرگ و زندگي در ميون است دیگه فکری به ذهنم نمیرسه لطفا اگه براتون ممكنه كمكم كنين
اين تكه كد براي اضافه كردن ايتم به سبد خريده اما مشكل اينجاس كه هيچوقت وارد حلقه نميشه و هر ايتمي كه براي كد پاس ميشه روي همون قبلي مينويسه در نتيجه آرايه ما هميشه فقط يك خونه داره
به نظر شما مشكل از كجاس؟
ضمنا بابت کمک قبلي ممنون
<?php
//$add is product id
$add=$_GET['add2cart'];
$shopping_cart=$_GET['shopping_cart'];
if (isset($shopping_cart))
{ if (isset($add) && $add>0)
{
//create shopping cart if there was not before
$is=isset($_SESSION["ids"]);
if ($is)
{
$_SESSION["ids"] = array();
$_SESSION["counts"] = array();
}
//check for product id that there was in cart before or not
$i=0;
while ($i<count($_SESSION["ids"]) && $_SESSION["ids"][$i] != $add) $i++;
//if there was in cart increase count
if ($i < count($_SESSION["ids"]))
{
$_SESSION["counts"][$i]++;
}
//if product id is new
else
{
$_SESSION["ids"][ ] = $add;
$_SESSION["counts"][ ] = 1;
}
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum