Select first 3 rows...

admin

Administrator
Staff member
Howdy,

I've got a script to select the first three rows in my table, but It's runs a bit slow because it's selecting so many records (i assume)

Can someone take a look and give me some pointers on how to make this run fasters. Here is the code:

$result = mysql_query("SELECT * FROM samsa_news order by id DESC",$db);
$data = "";
$spacer="----------------------------------------------";
if($result) {


for($i = 0; $i < 3; $i++) {

$myrow = mysql_fetch_array($result);

$date = strtoupper(rawurlencode($myrow["date"]));
$body = strtoupper(rawurlencode(strip_tags($myrow["body"])));
$data.= "$spacer\n$date\n$spacer\n$body\n\n\n\n";

}
}
echo "myNews=$data";
}
 
Back
Top