Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Back]
- <?php
- include_once ("Script/Connect.php");
- include_once("Script/check_log.php");
- if(!isset($_SESSION['ID'])){
- header("location: index.php");
- exit();
- }
- $user_costumer = $_SESSION['ID'];
- //These variables declared as global.
- $cart = '';
- $cart_action = '';
- $cartArray = "";
- $cartCount = "";
- $cartSlice = "";
- $cartSum="0";
- $userBalance="";
- $newBalance="";
- $file_link = "";
- $product_name = "";
- $product_price = "";
- $cart_top = "";
- $Q="";
- $QP="";
- $newQ=""; //To be used later
- $cart_bottom = "";
- $cart_id = "";
- $sql2 = mysql_query("SELECT * FROM checkout WHERE U_ID='$user_costumer'")or die(mysql_error());
- $count = mysql_num_rows($sql2);
- if($count > 0){
- while($row = mysql_fetch_array($sql2)){
- $cart_shop = $row["Cart"];
- $cart_id = $row["ID"];
- $Q=$row['Quantity'];
- if($cart_shop != '')
- {
- $cart_action = '
- <form action="shopping_cart.php" method="post" enctype="multipart/form-data">
- <input type="submit" name="submit" class="cart_action_yes" value="Check out" />';
- }
- else
- {
- $cart_action = '<div class="cart_action_none">Check out</div>';
- }
- if ($cart_shop != "")
- {
- $cartArray = explode(",", $cart_shop);
- $cartCount = count($cartArray);
- $cartSlice = array_slice($cartArray, 0, 50);
- $i = 0;
- foreach ($cartSlice as $key => $value)
- {
- $i++;
- $file_link = 'Catgs/' . $value . '.jpg';
- $image = '<img src="' . $file_link . '" width="40" height="40" border="0" />';
- $sql3 = mysql_query("SELECT Name, Price FROM mobiles WHERE id='$value'") or die ("Sorry we had a mysql error!");
- while($row = mysql_fetch_array($sql3)){
- $product_name = $row["Name"];
- $product_price = $row["Price"];
- $QP=$Q*$product_price;
- $cartSum+= $product_price;
- }
- $cart_top = '
- <table width="90%" cellpadding="3" cellspacing="0" border="1">
- <tr>
- <td width="40" align="center" height="40"></td>
- <td>Product name</td>
- <td width="70" align="center">Quantity</td>
- <td width="40" align="center">Price</td>
- </tr>
- ';
- $cart .= '
- <tr>
- <td width="45" align="center" height="40"><a href="view.php?id=' . $value . '">' . $image . '</a></td>
- <td><p class="text">' . $product_name .'</p></td>
- <td align="center"><input type="text" class="text_input" style="width: 20px;" maxlength="2" value="'.$Q.'"/><br/>
- <input type="submit" value="Update"/></td> <-- Here
- </td>
- <td width="70" align="center"><p class="price"> ' . $QP .' JOD</p></td>
- </tr>
- ';
- $cart_bottom = '
- <tr>
- <td colspan="3" style="padding: 3px;"><h3>Total price: </h3></td>
- <td width="70" align="center"><p class="price"> ' . $cartSum .' JOD</p></td>
- </tr>
- </table>
- ';
- }
- }
- }
- }else{
- $cart = "<b>In this moment you don't have a shopping cart, in order to have one go buy something.</b>";
- }
- /*$BSQL=mysql_query("Select Balance from users where ID='$user_costumer'") or die (mysql_error());
- while($row=mysql_fetch_array($BSQL))
- {
- $userBalance=$row["Balance"];
- if($userBalance<$cartSum)
- {
- echo '<p style="color:red"> Fetch error, please be back later<p>';
- }
- else
- $newBalance=$userBalance-$cartSum;
- if(isset($_POST['submit'])){
- $sql = mysql_query("UPDATE users SET Balance='$newBalance' WHERE ID='$user_costumer' ") or die (mysql_error());
- $cart_action='<p style="color:red">Thanks for your shopping! Have a nice day!<p>';
- }
- }*/
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement