I draw a do while news to the page by id , but when adding a new news, it appears at the very bottom. How to start a loop in reverse order?

Here is the code:

  do { if(!$myrow['img']){ printf (" <div class='news_content'> <a href='/news?id=%d'><img src='images_site/no-image.png'/></a> <div class='news_main'> <p class='time_comment'>%s</p> <a href='/news?id=%d'><h4 class='time_comment'>%s</h4></a> <p class='time_comment_p'>%s</p> <a class='readon' href='/news?id=%d'>Читать продолжение</a> </div> </div>", $myrow['id'], $myrow['date'], $myrow['id'], $myrow['title'], $result, $myrow['id']); } else { printf (" <div class='news_content'> <a href='/news?id=%d'><img src='%s'/></a> <div class='news_main'> <p class='time_comment'>%s</p> <a href='/news?id=%d'><h4 class='time_comment'>%s</h4></a> <p class='time_comment_p'>%s</p> <a class='readon' href='/news?id=%d'>Читать продолжение</a> </div> </div>", $myrow['id'], $myrow['img'], $myrow['date'], $myrow['id'], $myrow['title'], $result, $myrow['id']); } } while ($myrow = mysql_fetch_array($resylt));` 
  • four
    The most reasonable option is to change the ORDER BY in the request so that the data $resylt into $resylt in the order you $resylt - cyadvert
  • do {} while () will popov Popov courses. Do not do this, otherwise you will occasionally receive strange errors. Use the usual while () {} - artoodetoo

1 answer 1

Make a request

 SELECT * FROM table_name ORDER BY id DESC 

Try it.

  • Thanks a lot helped "ORDER BY id DESC". Please explain what kind of action is "ORDER BY id DESC"? - Vladislav
  • Everything has changed, only now the text in the lessons is the same ((What should I do? - Vladislav