hello
i ve been trying to make shopping cart with the help of Arrays and Sessions,what I ve been trying to check session var existance if it does then set session var to Array Variable.I am doing something like this
************************************************************
$pid=$_GET['id'];
if( isset($_SESSION['pid'])¦¦ isset($_SESSION['pqty']) ¦¦ isset($_SESSION['pprice'])&&isset($_SESSION['pname']) )
{
echo("all set");
$arrPid=array($_SESSION['pid']);
$arrPQty=array($_SESSION['pqty']);
$arrPName=array($_SESSION['pname']);
$arrPprice=array($_SESSION['pprice']);
}
if(in_array('$pid',$arrPid))
{
$isFound=1;
}
else
{
$isFound=0;
}
echo($isFound);
// if NOt FOUND then push new values
if($isFound==0)
{
$ret_name=array_push($arrPName,$Pname);
}
$_SESSION['pid']=$arrPid;
print_r($_SESSION['pid']);
Ooutput: first it works fine like print_r($_SESSION['pid']) gives
Array ( [0] => A-14 [1] => A-13 ) when i insert 2 different values
3rd time ifi insert say A-15 then it does
Array ( [0] => A-15 [1] => A-15 ) then now whatever i put i overwrites value
Any idea how do make cart with help of array and sessions
Help me please
-adnan