Jump to content

[SOLVED] PHP while loop limit (help plz)


Darkwoods

Recommended Posts

hi im trying to make a 5 limit loops for this code but without any success can anybody help plz

 

<?php 

        $result = mysql_query("SELECT * FROM news ORDER BY id DESC",$connect);

        while($row = mysql_fetch_array($result))

            {

 

echo '<div class="title">';

        echo $row['title'];

echo '</div>';

}

?>

Link to comment
https://forums.phpfreaks.com/topic/129148-solved-php-while-loop-limit-help-plz/
Share on other sites

<?php   
        $result = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT 5",$connect);
        while($row = mysql_fetch_array($result))
             {
          
      echo '<div class="title">';
        echo $row['title'];
      echo '</div>'; 
      }      
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.