Which parameters to use in mysql_fetch_array

1

Hello, I do not know what parameters (I only know one of them) to use in mysql_fetch_array, please tell me what it is and how to get it.

    include "conection.php";

session_start(0);

$db = mysqli_connect("localhost", "root", "");
$login = $_SESSION['login_usuario'];

$sql = mysqli_query($db, "SELECT * FROM usuarios WHERE login = '$login'");

while($linha = mysql_fetch_array($sql, $sql))
{
    $nome = $linha['nome'];
    $email = $linha['email'];
    $idade = $linha['idade'];
    $cidade = $linha['cidade'];
}

Thank you in advance.

    
asked by anonymous 25.04.2015 / 00:46

1 answer

3
  

I just wanted to know what exactly I should put in the second parameter   of mysql_fetch_array.

The second argument is optional, it indicates what type of array should be returned.

Possible values are: MYSQLI_ASSOC , MYSQLI_NUM , or MYSQLI_BOTH .

By default, the mysqli_fetch_array() function will assume MYSQLI_BOTH for this parameter.

  • MYSQLI_ASSOC : Returns an associative array .
  • MYSQLI_NUM : Returns an array with numeric index.
  • MYSQLI_BOTH : Returns an array with both indexes, numeric and associative ( multidimensional ).
25.04.2015 / 01:29