Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-08-2006, 11:18 PM   PM User | #1
xsnoboard
New Coder

 
Join Date: Dec 2005
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
xsnoboard is an unknown quantity at this point
Help Sorting Category

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...
Code:
$rt = mysql_query("SELECT * FROM files ORDER BY $sort $order");

 while($filelist_array = mysql_fetch_array($rt)){
__________________
"Help me, Help you"

KnastyDotCom - 100% Original Videos and Pictures and more!
xsnoboard is offline   Reply With Quote
Old 01-09-2006, 12:10 AM   PM User | #2
ralph l mayo
Regular Coder

 
ralph l mayo's Avatar
 
Join Date: Nov 2005
Posts: 951
Thanks: 1
Thanked 31 Times in 29 Posts
ralph l mayo is on a distinguished road
SELECT * FROM files ORDER BY posted DESC

posted is whatever column holds your timestamp, DESC means DESCending, last (most recent) first
ralph l mayo is offline   Reply With Quote
Old 01-09-2006, 12:12 AM   PM User | #3
xsnoboard
New Coder

 
Join Date: Dec 2005
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
xsnoboard is an unknown quantity at this point
but i need it so it only shows the category videos or category pictures in most recent order
__________________
"Help me, Help you"

KnastyDotCom - 100% Original Videos and Pictures and more!
xsnoboard is offline   Reply With Quote
Old 01-09-2006, 12:26 AM   PM User | #4
ralph l mayo
Regular Coder

 
ralph l mayo's Avatar
 
Join Date: Nov 2005
Posts: 951
Thanks: 1
Thanked 31 Times in 29 Posts
ralph l mayo is on a distinguished road
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
ralph l mayo is offline   Reply With Quote
Old 01-23-2006, 01:20 AM   PM User | #5
xsnoboard
New Coder

 
Join Date: Dec 2005
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
xsnoboard is an unknown quantity at this point
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
__________________
"Help me, Help you"

KnastyDotCom - 100% Original Videos and Pictures and more!
xsnoboard is offline   Reply With Quote
Old 01-23-2006, 03:16 PM   PM User | #6
degsy
Senior Coder

 
Join Date: Nov 2002
Location: North-East, UK
Posts: 1,265
Thanks: 0
Thanked 0 Times in 0 Posts
degsy is on a distinguished road
Code:
$rt = mysql_query("SELECT * FROM files ORDER BY $sort $order");

PHP Code:
<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.
degsy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:36 PM.


Advertisement
Log in to turn off these ads.