mysqli_num_row error

Asked

Viewed 19 times

0

I am unable to show the column count in the database. For example I want to show in the panel how many orders are registered. For this I want the ID count.

include 'conexao.php';
$pedidosq = "SELECT id FROM pedido";
$pedidos = mysqli_num_rows($pedidosq);

To display I give an echo,

<?php  echo $pedidos ?>

However, nothing appears. The connection to the database is Ok.

1 answer

0

In $pedidosq you are just adding a String to the variable, you need to run the query in the database to get the results and capture the amount of lines from the result.

$pedidosq = mysqli_query($conexao, "SELECT id FROM pedido");
$pedidos = $pedidosq -> num_rows;
echo $pedidos;
  • Exactly. I noticed immediately after posting. I fixed it and it’s perfect. Thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.