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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    sorting by drop down...

    can anyone please teach me how to do this kind of thing?

    http://squareinsider.com/news/archive.php


    As you can see, theres a dropdown... and when you choose one in the drop down, it shows the articles that matches the category...

    Im trying to do the same but with not news articles but fanarts...

    I only have this so far..
    (this is fanart.php)

    $sql = mysql_query('SELECT DISTINCT artist FROM site_fanartsindex');


    for ($x = 0; $x < mysql_num_rows($sql); $ex++)
    {
    $row3 = mysql_fetch_array($sql);
    $artist = $row['artist'];
    $showartist .= "<option value=fanartartist.php?artist={$artist}>$artist</option>";



    echo "
    <select class="form" onchange="window.open(this.options[this.selectedIndex].value,'_self')" size="1" name="page">
    <option value="#">ARTIST</option>
    <option value="#">-----------------------------</option>
    $showartist
    </select>




    then in fanartist.php



    $sql = mysql_query("SELECT * FROM site_fanartsindex WHERE artist=$artist");

    ECHO "STUFF HERE, got this part done, this is the easy one ^^ "






    basically, can anyone provide more "lectures", fixes and stuff. I have never tested the code and I DOUBT it will work.


    thanks!

  • #2
    Az`
    Az` is offline
    New Coder
    Join Date
    Mar 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    IF you don't have globals on, you'll need to put $_POST['artist'].

    But, actually it looks like you've named the jumpmenu 'page' - Therefore you'd have to use:
    PHP Code:
    $page $_POST['page'];

    $sql mysql_query("SELECT * FROM site_fanartsindex WHERE artist = 'page'"); 

    Remember the option value is whatever you're assigning to the 'name' variable.
    Remember that:

    <option value="#">ARTIST</option>

    There, as far as values are concerned, ARTIST is merely output to the browser, it's the 'value="#"' bit that counts.


  •  

    Posting Permissions

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