Reply to Re: [PHP] sorting mysql results

Your name:

Reply:


Posted by Leif Gregory on 10/04/87 11:05

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>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация