how to use mysqli_fetch_array

4

I would like to know how I use this command mysql in my code because I am trying and nothing can not make it work if someone can help thanks.

code:

 $sql = mysqli_query($mysqli, "SELECT * FROM produtos LIMIT $inicio, $totalProduto");
            while($aux = mysqli_fetch_array($mysqli, $sql)){
              $id = $aux['id_produto'];
              $nome = $aux['nome'];
              $desc = $aux['descricao'];
              $preco = $aux['preco'];
              $categoria = $aux['categoria'];
              $img = $aux['img'];
              $tipo = $aux['type'];
              $size = $aux['size'];
    
asked by anonymous 16.12.2015 / 18:13

1 answer

5

mysqli_fetch_array() gets only one argument that is the return of mysqli_query() and not the connection.

Switch to:

 while($aux = mysqli_fetch_array($sql)){

When using the MySQL procedural style in QUESTION all functions the first argument is the connection, mysqli_fetch_*() is an exception to this rule.

View the function signature

  

mixed mysqli_fetch_array (mysqli_result $ result [ int $ resulttype = MYSQLI_BOTH])

Documentation - fetch_array ()

Documentation - Function List

    
16.12.2015 / 18:18