0

This is a receipt I'm trying to generate but i also need it to deduct quantity from our webshop. It works correctly when I only put one product through but I want it to work for each product displayed on the receipt.

<?php $r = 1; foreach ($rows as $row):?>


        <tr>

            <td style="text-align:center; width:30px;"><?php echo $r; ?></td>

            <td style="text-align:left; width:180px;"><?php echo $row->product_code; ?></td>

            <td style="text-align:center; width:50px;"><?php echo $row->quantity; ?></td>

            <td style="text-align:right; width:70px; "><?php echo $row->gross_total; ?></td>

        </tr> 

<?php

    mysqli_query($con,"UPDATE product SET quantity = quantity - '$row->quantity;' WHERE mpn = '$row->product_code'");

    mysqli_close($con);

?>

<?php $r++; endforeach; ?>

Upon adding more than 1 item to the receipt I get this error.

A PHP Error was encountered

Severity: Warning Message: mysqli_query(): Couldn't fetch mysqli Filename: views/view.php Line Number: 142

2
  • Is ur mysqli extension enabled in PHP.ini?? Commented Aug 12, 2014 at 11:50
  • 2
    '$row->quantity;' <- what's the semicolon doing there? Commented Aug 12, 2014 at 11:51

1 Answer 1

1

take mysqli_close($con); after endforeach;

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.