M12_GTO
06-03-2005, 07:11 PM
Can anyone tell me why the following code only displays 1 line with one character no matter how many times the links at the bottom are clicked?
Am I right in thinking this code should populate the next element in the array upon clicking the links?
<?php
session_start();
session_register("count");
$_SESSION['cart'] = array();
if(!isset($count))
$_SESSION['count'] = 0;
$_SESSION['count']++;
$qs = $_GET['action'];
if($qs == "a")
$_SESSION['cart'][$_SESSION['count']] = "a";
if($qs == "b")
$_SESSION['cart'][$_SESSION['count']] = "b";
if($qs == "c")
$_SESSION['cart'][$_SESSION['count']] = "c";
foreach($cart as $index => $value) {
print("Cart: " . $value . "<BR>");
}
print("<A HREF='session.php?action=a'>A</A><BR>");
print("<A HREF='session.php?action=b'>B</A><BR>");
print("<A HREF='session.php?action=c'>C</A><BR>");
?>
Am I right in thinking this code should populate the next element in the array upon clicking the links?
<?php
session_start();
session_register("count");
$_SESSION['cart'] = array();
if(!isset($count))
$_SESSION['count'] = 0;
$_SESSION['count']++;
$qs = $_GET['action'];
if($qs == "a")
$_SESSION['cart'][$_SESSION['count']] = "a";
if($qs == "b")
$_SESSION['cart'][$_SESSION['count']] = "b";
if($qs == "c")
$_SESSION['cart'][$_SESSION['count']] = "c";
foreach($cart as $index => $value) {
print("Cart: " . $value . "<BR>");
}
print("<A HREF='session.php?action=a'>A</A><BR>");
print("<A HREF='session.php?action=b'>B</A><BR>");
print("<A HREF='session.php?action=c'>C</A><BR>");
?>