you can either use the limit in your query
select * from table limit 5
or depending on how you retrieve you data in PHP you can also break out of the loop after 5 rows are returned
ex :
$query="select * from table";
$res=odbc_exec($query);
$i=0;
while($row=odbc_fetch_array($res)) {
do your stuff here
if($i++==5) break;
}
i don't especially like the second method, and i'm sure there are others.