...

View Full Version : Help Sorting Category



xsnoboard
01-08-2006, 11:18 PM
I want to have my link list to be sorted by Category.. etc Category Videos or Pictures... and so that the most recent is at the top and it just shows either pictures or videos


This is my other code I have for sorting.. I would prolly have to add something similiar below this code...

$rt = mysql_query("SELECT * FROM files ORDER BY $sort $order");

while($filelist_array = mysql_fetch_array($rt)){

ralph l mayo
01-09-2006, 12:10 AM
SELECT * FROM files ORDER BY posted DESC

posted is whatever column holds your timestamp, DESC means DESCending, last (most recent) first

xsnoboard
01-09-2006, 12:12 AM
but i need it so it only shows the category videos or category pictures in most recent order

ralph l mayo
01-09-2006, 12:26 AM
if you're doing one at a time use SELECT * FROM files WHERE category='foo' ORDER BY posted DESC

or if you're doing both (I think, this might not be what you want)
SELECT * FROM files GROUP BY category ORDER BY posted DESC

xsnoboard
01-23-2006, 01:20 AM
i still can't seem to figure this out... I want it so it just displays my categories separetly... So they can click videos and it just shows the videos etc.. instead of all of them mixed...

Videos
Pictures
Flash
Articles

degsy
01-23-2006, 03:16 PM
$rt = mysql_query("SELECT * FROM files ORDER BY $sort $order");




<a href="page.asp?cat=Videos&order=DESC">Videos</a>

$cat=$_GET['cat'];
$order=$_GET['order'];

$rt = mysql_query("SELECT * FROM files WHERE category='$cat' ORDER BY name $order");


You probably want to do some validation on the variables & query, but that it is basic type of query and hyperlink.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum