PHP Code:
if(isset($_POST['add'])){
foreach($_SESSION as $ps => $value){
$getcartname = (explode('_', $ps));
if($getcartname[0] == 'ps'){
$getLine = (explode('_', $ps));
$line = $getLine[0];
$getVal = (explode('_', $value));
$arrayContent = $getVal[0];
$arrTotal += $arrayContent;
}
}
if($line == ''){
$line = 1;
}
else{
$line++;
}
$_SESSION['ps_'.$line] = $num.'_'.$totalqtyt.'_'.$amount;
tempList();
}
The script is suppose to do...
If add has been set, check the array with ps_ if $line is NULL meaning the array is empty, set the $line to 1 if not increment $line.
My problem is it doesnt seem to increment line after the first 'clicking' of $_POST['add']; What seems to be the problem?