//info for the DB
$username="TelcomH_Code1";
$password="93Lq15jsl";
$database="TelcomH_telcomshop";
$host="mysql1-dal1.u2-web.com";
//get list of categories or items in store
//connect to db
$conn = mysql_connect($host, $username, $password) or die ('Error connecting to mysql');
mysql_select_db($database);
function AddItem($itemId, $qty)
{
$result = mysql_query("select * from tblCart where cartCookieId = '" . $_SESSION['cartID'] . "' and cartItemId = $itemId");
$row = mysql_fetch_array($result);
$numRows = mysql_num_rows($result);
if($numRows == 0)
{
// This item doesn't exist in the cart;
// insert new item if in stock
$result = mysql_query("select itemQnty from tblItems where itemId = $itemId");
$row = mysql_fetch_array($result);
if ($row["itemQnty"] >= 1)
{
@mysql_query("insert into tblCart(cartCookieId, cartItemId, cartQty) values('" . $_SESSION['cartID'] . "', $itemId, $qty)");
} else {
echo ('We\'re sorry, but we do not have that item in stock. Your cart has been updated to reflect this.
');
RemoveItem($itemId);
}
}
else
{
//Update item instead
$qty = $row["cartQty"] + 1;
UpdateItem($itemId, $qty);
}
}
function UpdateItem($itemId, $qty)
{
$result = mysql_query("select itemQnty from tblItems where itemId = $itemId");
$row = mysql_fetch_array($result);
if ($row["itemQnty"] >= $qty)
{
mysql_query("update tblCart set cartQty = $qty where cartCookieId = '" . $_SESSION['cartID'] . "' and cartItemId = $itemId");
} elseif ($row["itemQnty"] == 0)
{
echo ('We\'re sorry, but we do not have that item in stock. Your cart has been updated to reflect this.
');
RemoveItem($itemId);
} else {
$qty = $row["itemQnty"];
mysql_query("update tblCart set cartQty = $qty where cartCookieId = '" . $_SESSION['cartID'] . "' and cartItemId = $itemId");
echo ('We\'re sorry, but we only have ' . $qty . ' of that item in stock. Your cart has been updated to reflect this.
');
}
}
function RemoveItem($itemId)
{
mysql_query("delete from tblCart where cartCookieId = '" . $_SESSION['cartID'] . "' and cartItemId = $itemId");
}
function ShowCart()
{
$result = mysql_query("select * from tblCart inner join tblItems on tblCart.cartItemId = tblItems.itemId where tblCart.cartCookieId = '" . $_SESSION['cartID'] . "' order by tblItems.itemName asc");
?>
Qnty
Title
Price
while($row = mysql_fetch_array($result))
{
// Increment the total cost of all items
$totalCost += ($row["cartQty"] * $row["itemPrice"]);
?>
Ordering Your order is placed when you click the "Submit Order!" button below. You will be taken to PayPal, through which you may pay using a credit card or through your PayPal account. After payment, you will be returned to our site and be sent a confirmation email from PayPal. Delivery times average 1-2 weeks.
Shipping rates Shipping and handling will be determined when you submit your order. In general, our rates are $10 per first book, record album and/or telephone, $4 thereafter; or $5 and $2.50 thereafter for everything else except Gift Memberships (which have no shipping cost). Combinations of books/records and other items will be sent at the lowest shipping rate possible ($10 for the first book, $4 per additional book/record and $2.50 per other item).
Gift Memberships Please remember to enter the recipient's name, mailing address, and phone number into PayPal's "Add special instructions to merchant" section when paying. We'll send a card along telling them you've bought them a membership.