Limiting A Result Using Php, Without Using Limit Clause When Fetching Rows In Database Query?
I have a table in SQL, it contains around 100 rows. I select it within PHP with SELECT * FROM table. I didn't use offset nor limit. My question now is, is there are way to manipula
Solution 1:
The general format for getting rows from the DB looks like this:
while ($row = mysql_fetch_assoc($rs)) {
echo$row['column_name'] . "\n";
}
You'll want to modify it like this:
$limit = 24;
while ($limit-- && $row = mysql_fetch_assoc($rs)) {
echo$row['column_name'] . "\n";
}
Solution 2:
Well, I guess now that the oracle
tag was added, I'll add the oracle answer.
$rows=array(row, row, row, ...); //from oracle sql results
$first_24_rows = array_slice($rows, 0, 24);
Solution 3:
You can control the number of rows return in the oracle SQL itself. Put something like this in the where clause:
and rownum <= 23
Post a Comment for "Limiting A Result Using Php, Without Using Limit Clause When Fetching Rows In Database Query?"