file - mysqli

Clau4786

Nuovo Utente
28 Set 2018
6
0
1
Ciao.

Vorrei chiedere un altro aiuto... io ho uno script che memorizza dei dati in un file. Sto cercando di capire come fare l'alternativa in mysqli.
PHP:
if(file_exists('righe.txt')){
      $lines = file('righe.txt');
}
print count($lines)."<br>";
print $lines[9]."<br>";

Il file righe.txt ha 100 righe.
Quindi il mio codice mi diche che ci sono 100 righe, e mi mostra la riga numero 9.

Da myqli come posso fare questo ?

PHP:
$db = new mysqli($db_host,$db_user, $db_password, $db_name);

$query = "SELECT * FROM righe";
$stmt = $db->prepare($query);
$stmt->execute();
$stmt->store_result();
$r = $stmt->num_rows; // qui ci sono. Ho le mie 100 righe.

$query = "SELECT * FROM chat2";
$stmt = $db->prepare($query);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_object(); //qui non ci sono. Come faccio per avere un array ?

Come faccio per avere un array ?
 

Discussioni simili