A
A
Artem2020-05-22 09:39:28
PHP
Artem, 2020-05-22 09:39:28

How to set the correct quantity invoice?

I set the number 4 but counts up to 5. How can I make the count stop at a given number? Thanks in advance !

$row = mysqli_fetch_array($data);
$new_count = $row["cart_count"];
$new_count++;
if ($new_count >= 1 & $new_count <= 4 ){ . . .

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Comsequent, 2020-05-22
@Comsequent

$new_count <= 4 Remove the equals
sign.

F
FanatPHP, 2020-05-22
@FanatPHP

nothing is clear from the code, but apparently you first increase, and therefore you check.
And you need $new_count++; put inside conditions.
Plus logical AND is two amersands, &&, not one

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question