Jump to content

[SOLVED] limit the while() results !


samoi

Recommended Posts

Hello guys, I need a little help to explain how to limit while loops !

 

if I want to get an info from the MySQL, using php script, and I need this info to be the last four (for example) desc result! how to get them?

 

an example:


<?php
// this is only an example I wrote now, please don't focus on other issues, teach me how to limit a while() loop.


include("configuration.php");


// let's say I need to see the last four registrants (the most recent)


$samoi = "SELECT username FROM users WHERE id < 4 ORDER BY registation_time desc"; // is this correct stament? I mean id < 4 but I need the last 4 registrants ! It dives me crazy !
$samoi_SQL = mysql_query($samoi);

    while($phpfreaks = mysql_fetch_assoc($samoi_SQL))

           {
              echo $phpfreaks['username'];
              echo "<br />";
           }

?>


 

I really appreciate your help

Link to comment
https://forums.phpfreaks.com/topic/142910-solved-limit-the-while-results/
Share on other sites

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.