I am trying to get a set of results seperated by their order of being returned.... for example, if i am returning 10 rows always, i would like to assign different variables to the selected columns for that row.. such as $row1[1] - $row1[2].. then $row2[1].. $row2[2].. What im basically doing is selecting top 10, and scattering the results in different areas of the site..
Any ideas on the best ways to do this?
Hope this makes sense.. heh..
Thanks!
Get specific results
Moderator: General Moderators
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Code: Select all
$q = 'SELECT * FROM table ORDER BY id DESC LIMIT 10';
$result = mysql_query($q);
if ($result) {
for ($i=0, $row = mysql_fetch_assoc($result); $i++) {
$store[$i] = $row;
}
} else echo 'Bad query';Fantastic, thanks!ole wrote:Code: Select all
$q = 'SELECT * FROM table ORDER BY id DESC LIMIT 10'; $result = mysql_query($q); if ($result) { for ($i=0, $row = mysql_fetch_assoc($result); $i++) { $store[$i] = $row; } } else echo 'Bad query';