I
I
Ibishka2020-05-01 04:17:07
PHP
Ibishka, 2020-05-01 04:17:07

How to display all products and at the same time find out how many there are in total?

I have to display the products and find out how many there are in total. The code works, but did I write it correctly, that is, could it be simpler?

$goods = mysqli_query($connection, "SELECT * FROM `goods` ORDER BY `id` ASC");
$goodsArr = mysqli_fetch_all($goods, MYSQLI_ASSOC);
foreach ($goodsArr as $item) {
...
}
echo count($goodsArr);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question