Forum Moderators: coopster
(modified example from kevin yanks book)
// Start Session
session_start();
if(!isset($_SESSION['shop']))
$_SESSION['shop'] = array();
if (isset($_GET['buy'])) {
// Add ROW['ID'] to the end of the $_SESSION['cart'] array
$_SESSION['shop'][] = $_GET['buy'];
header('location: ' . $_SERVER['PHP_SELF'] . '?' . $SID);
meanwhile:
echo('
<td><center><a href=\" ' . $_SERVER['PHP_SELF'] . '?buy=' . $row['ID'] . ' \"></center></td>');
I can't seem to get the format correct to get the href to show up. The rest of the table is fine and this produces no errors.
This is returning the rowid in the browser but PHP_SELF is not working:
<td><center><a href=\".$_SERVER['PHP_SELF'] .?buy=" .$row['ID']."\">buy</a></center></td>
Rather than:
echo('
<td><center><a href=\" ' . $_SERVER['PHP_SELF'] . '?buy=' . $row['ID'] . ' \"></center></td>');
Try:
echo('
<td><center><a href="'.$_SERVER['PHP_SELF'].'?buy='.$row['ID'].'"></center></td>');
You only need to escape the double quotes if you are using double quotes to enclose the string you are echoing.