It is necessary to add the last three lines to the array from the database table, how can this be done?

include('connections/trooble.php'); $q = mysql_query("SELECT * FROM test ORDER BY (`id`) DESC LIMIT 3"); $r = mysql_fetch_array($q); while ($r = mysql_fetch_array($q)) { $n[] = $r['news']; } $i = 0; while ($i < 3) { $a = $n[$i]; $i++; echo $a; } 

It seems everything is correct, but does not display the very first news.

    2 answers 2

    If truly understood that:

     $query = mysql_query("SELECT * FROM `table` ORDER BY (`id`) DESC LIMIT 3"); while($result = mysql_fetch_array($query)) { //Result of the array } 
    • "// Result of the massif" - O_o why "massif" and not "array"?)) - namak
    • one
      Changed to an array if it sees the eye better) - Palmervan
    • one
      array is more familiar))) - namak
     $r = mysql_fetch_array($q); while ($r = mysql_fetch_array($q)) { $n[] = $r['news']; } 

    Here, in my opinion, the first line is redundant .... it turns out that two times in a row a fetch is made, but after the first one, the array is not written. Sorry for my bad Russian.