select_db($dbname);
/* if (array_key_exists(‘submitremove’, $_POST))
{
$removeline = $_POST(“removeline”);
//$query = “DELETE FROM holdingcart WHERE cartrecordid = ‘$removeline’ AND SessionID = ‘$session_id'”;
$result = $db->query(“DELETE FROM holdingcart WHERE cartrecordid = ‘$removeline’ AND SessionID = ‘$session_id'”);
} */
if ($_POST[‘submitremove’] == “Remove”)
{
$removeline = $_POST[‘removeline’];
//$query=”DELETE FROM holdingcart WHERE cartrecordid = ‘$removeline’ AND SessionID = ‘$session_id'”;
$erase = $db->query(“DELETE FROM holdingcart WHERE holdingcart.cartrecordid = ‘$removeline'”);
} else { };
$returnlink = $_GET[‘merchant_return_link’];
if (isset($returnlink))
{
$clearcart = $db->query(“DELETE FROM holdingcart WHERE SessionID = ‘$session_id'”);
echo “
for ($s=0; $s < $show_num_results; $s++)
{
$srow = $shows->fetch_assoc();
$shownameupper = strtoupper($srow[‘Name’]);
$showname = ($srow[‘Name’]);
$showid = ($srow[‘ShowID’]);
$postid = ($srow[‘postid’]);
$query=”SELECT Time, PerfID FROM performances WHERE performances.Time > NOW() AND ShowID = ‘$showid’ ORDER BY performances.Time;”;
$result = $db->query($query);
$num_results = $result->num_rows;
echo ‘
‘;
$query=”SELECT TicketType, Price FROM prices WHERE Category = (SELECT meta_value FROM wp_postmeta WHERE meta_key = ‘category’ AND post_id = ‘$postid’) ORDER BY Price DESC;”;
$result = $db->query($query);
$num_results = $result->num_rows;
echo ‘
‘;
echo ‘
‘;
echo ‘
‘;
echo ‘
‘;
}
/* WRITING NEW POSTS TO CART */
if ($_POST[‘post’] == “Add to Cart”) {
$ticket = $_POST[‘ticket’];
$performance = $_POST[‘performance’];
$qty = $_POST[‘qty’];
$alreadyadded=”SELECT quantity FROM holdingcart WHERE tickettype = ‘$ticket’ AND PerfID = ‘$performance’ AND SessionID = ‘$session_id'”;
$aaresult = $db->query($alreadyadded);
$num_results = $aaresult->num_rows;
for ($i=0; $i < $num_results; $i++) {
$row = $aaresult->fetch_assoc();
$aaqty = $row[‘quantity’];
}
if ($qty > 0) {
if ($aaqty > 0) {
$newqty = $aaqty+$qty;
$posttocart = “UPDATE holdingcart SET quantity = ‘$newqty’ WHERE tickettype = ‘$ticket’ AND PerfID = ‘$performance’ AND SessionID = ‘$session_id'”;
} ELSE {
$posttocart = “INSERT INTO $dbname.holdingcart (PerfID, SessionID, Date, tickettype, quantity) VALUES (‘$performance’,’$session_id’,NOW(),’$ticket’,’$qty’);”;
} $result = $db->query($posttocart); } }
echo ‘
‘;/* var_dump($_POST); */
echo ‘
‘;/* DISPLAY OF SHOPPING CART */
$cartquery=”SELECT shows.Name AS cartname, performances.Time AS cartperf, holdingcart.tickettype AS type, holdingcart.quantity AS qty, prices.Price AS Price, holdingcart.quantity*prices.Price AS subtotal, holdingcart.cartrecordid AS itemid, holdingcart.PerfID as PerfID, shows.ShowID as ShowID FROM shows, performances, holdingcart, prices WHERE shows.ShowID = performances.ShowID AND performances.PerfID = holdingcart.PerfID AND prices.TicketType = holdingcart.TicketType AND prices.Category = shows.Category AND holdingcart.SessionID = ‘$session_id'”;
$cart = $db->query($cartquery);
$num_results = $cart->num_rows;
$total = 0;
?>
fetch_assoc();
echo ‘
‘;
/* SET VARIABLES TO PASS TO PAYPAL – CART METHOD */
$paypalitem = ‘paypalitem’.$i;
$$paypalitem = $row[‘cartname’].’ – ‘.date(“D jS M, g:i A”, strtotime(htmlspecialchars(stripslashes($row[‘cartperf’]))));
$paypalitemnumber = ‘paypalitemnumber’.$i;
$$paypalitemnumber = $row[‘PerfID’];
$paypaltickettype = ‘paypaltickettype’.$i;
$$paypaltickettype = $row[‘type’];
$paypalshowid = ‘paypalshowid’.$i;
$$paypalshowid = $row[‘ShowID’];
$paypalqty = ‘paypalqty’.$i;
$$paypalqty = $row[‘qty’];
$paypalprice = ‘paypalprice’.$i;
$$paypalprice = $row[‘Price’];
$itemid = $row[‘itemid’];
echo ‘
‘;
} else { echo ‘
‘;
?>