Re: sorting mysql results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Sebastian,

Monday, January 10, 2005, 2:38:18 PM, you wrote:
S> if the $row['type'] is music i want to output an <hr> and the
S> results below it but below the files results.. makes sense? i
S> thought i remember doing this once using a dummy var but cant
S> remember how. i guess i could always run a second query, but would
S> like to avoid that.

As you loop through the recordset, just concatenate.

i.e.

while ($r=mysql_fetch_assoc($result))
{
  if ($row['type'] == "Music")
    $musicRows .= $row['name'] . '-' . $row['type'] . '<br>';

  elseif ($row['type'] == "Files")
    $fileRows .= $row['name'] . '-' . $row['type'] . '<br>';

  elseif ($row['type'] == "Pictures")
    $pictureRows .= $row['name'] . '-' . $row['type'] . '<br>';
}

echo 'FILES<br>-----<br>' . $fileRows . '<br><br>';
echo 'MUSIC<br>-----<br>' . $musicRows . '<br><br>';
echo 'PICTURES<br>--------<br>' . $pictureRows . '<br><br>';


I threw PICTURES in there just for GPs.



Cheers,
Leif Gregory 

-- 
TB Lists Moderator (and fellow registered end-user)
PCWize Editor  /  ICQ 216395  /  PGP Key ID 0x7CD4926F
Web Site <http://www.PCWize.com>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux