Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Dec 2005
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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!

  • #2
    Regular Coder ralph l mayo's Avatar
    Join Date
    Nov 2005
    Posts
    951
    Thanks
    1
    Thanked 31 Times in 29 Posts
    SELECT * FROM files ORDER BY posted DESC

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

  • #3
    New Coder
    Join Date
    Dec 2005
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #4
    Regular Coder ralph l mayo's Avatar
    Join Date
    Nov 2005
    Posts
    951
    Thanks
    1
    Thanked 31 Times in 29 Posts
    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

  • #5
    New Coder
    Join Date
    Dec 2005
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #6
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •