connection close - before or after?

1

What's best, close before or after while?

For example, Mode1 :

$sql= "SELECT * FROM tabela";
$rs = mysql_query($sql,$connect);

mysql_close($connect);

while($row = mysql_fetch_array($rs)){
  $nome = $row['nome'];
  echo $nome;
}

or Mode2:

 $sql= "SELECT * FROM tabela";
    $rs = mysql_query($sql,$connect);

    while($row = mysql_fetch_array($rs)){
      $nome = $row['nome'];
      echo $nome;
    }

    mysql_close($connect);
  • The close before or after the while? Mode1 or Mode2?
asked by anonymous 09.02.2018 / 13:09

0 answers