Page 1 of 1

Get specific results

Posted: Fri Jul 28, 2006 9:18 pm
by GeXus
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!

Posted: Sat Jul 29, 2006 5:08 am
by Ollie Saunders

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';

Posted: Sat Jul 29, 2006 10:48 am
by GeXus
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';
Fantastic, thanks!