MySQL Forums
Forum List  »  PHP

Is there anybody to help me in this code please???
Posted by: Zohra Pardesi
Date: June 08, 2019 01:41PM

Hi Friends,

I am learning website development from youtube tutorials and stuck at some point, it would be appreciated if someone help me out in code.

This is related to online store website.
If my database contains Lipstick 10 and Foundations 5.

User gets login and add both of above products into cart then she updates quantity of Lipstick to 12 and quantity of Foundation to 3.

in both above cases order place successfully and payment also gets done bill generate.............. which is not right as user's ordered quantity is more than the quantity available.

I tried to resolve the issue but as I am not expert and I am in learning phase so, I could not resolve the issue.

please have a look at my code and let me know how to resolve this issue???? I will really be grateful to you.

////////////////This is the Part of code where user gets login

$get_user=$conn->prepare("select * from zusers where u_email='$u_email'");
$get_user->setFetchMode(PDO:: FETCH_ASSOC);

$cart_item=$conn->prepare("select * from zuser_cart where ip_add='$ip' AND user_id='$user_id'");
$cart_item->setFetchMode(PDO:: FETCH_ASSOC);

$get_product=$conn->prepare("select * from zproducts where product_id='$product_id'");
$get_product->setFetchMode(PDO:: FETCH_ASSOC);

if(($row['qty']) > $q){
echo "<script>alert('Your Required Quantity is more than the Quantity Available!);</script>";



echo "<center><h2>No Item Found, Your Cart is Empty!!! &nbsp &nbsp;<a href='cat-detail.php?cat_id=1'>Continue Shopping</a></h2></center>";
}else {
if(isset($_POST['update_qty']) AND !empty($_POST['qty'])){

if($quantity > $q){
echo "<script>alert('Your Required Quantity is more than the Quantity Available!');</script>";

foreach($quantity as $key=>$value){
$update_qty=$conn->prepare("update zuser_cart set qty=:value
where user_cart_id='$key'");
$update_qty->bindParam(":value", $value);
echo "<script>'checkout.php?checkout_cart','_self')</script>";
echo "<script>'user-profile.php?mycart','_self')</script>";

echo "<table>
<th>Product Name</th>
<th>Sub Total</th>
<th>Remove Item</th>
$get_product=$conn->prepare("select * from zproducts where product_id= '$product_id'");
$get_product->setFetchMode(PDO:: FETCH_ASSOC);

<td><img src='images/products_images/".$row_product['product_img1']."' /></td>
<td><input type='text' name='qty[".$row['user_cart_id']."]' value='".$row['qty']."' />
<input type='submit' name='update_qty' value='Save' /></td>
echo $sub_total;
echo "</td>
<td><a href='delete-cart.php?user_delete_id=".$row_product['product_id']."'>Delete</a></td>

Options: ReplyQuote

Written By
Is there anybody to help me in this code please???
June 08, 2019 01:41PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.