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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2006
    Posts
    110
    Thanks
    1
    Thanked 0 Times in 0 Posts

    ascend / descend with GET

    I cant figure out why this doesnt work.
    I can specify the sort of my returned data from FileMaker by sending a paramater of "ascend" or "descend" -
    So, when I try to use GET links to sort my table, I can't seem to get it to switch from descend to ascend (back and forth) by clicking the same link.
    Does the error seem apparent to anyone?
    I can't seem to get it.

    here is my php:
    PHP Code:
    <?php
    $sortpref
    =$_GET['sortpref'];
    $sortstyle=$_GET['sortstyle'];
    if(!isset(
    $_GET['sortpref']))
    {
    $sortpref="TimeStamp";
    $sortstyle="descend";
    }
    ?>
    and here is the HTML (and php) that I'm trying to use for my links:

    PHP Code:
    <tr>
    <td><center><b><a href="http://blahblah/admintools.php?sortpref=TimeStamp&sortstyle=
    <?php 
    if($sortstyle "descend")

    print 
    "ascend";
    }
    elseif(
    $sortstyle "ascend")
    {
    print 
    "descend";
    }
    ?>">TimeStamp</a></b></center></td>
    <td><center><b><a href="http://blahblah/admintools.php?sortpref=Username">Username</a></b></center></td>
    <td><center><b><a href="http://blahblah/admintools.php?sortpref=WebAccountNumber">WebAccount#</a></b></center></td>
    <td><center><b><a href="http://blahblah/admintools.php?sortpref=Browser">Browser</a></b></center></td>
    <td><center><b><a href="http://blahblah/admintools.php?sortpref=Version">Version</a></b></center></td>
    <td><center><b><a href="http://blahblah/admintools.php?sortpref=Res">Resolution</a></b></center></td>
    </tr>
    My tests have only been with the first link - - I figured once I got it working I would do the same with the rest.

    Does anyone have any thoughts??

  • #2
    Regular Coder ralph l mayo's Avatar
    Join Date
    Nov 2005
    Posts
    951
    Thanks
    1
    Thanked 31 Times in 29 Posts
    You're assigning the variable $sortstyle instead of testing it in the second part, you want the == operator and not =.

  • #3
    Regular Coder
    Join Date
    Jul 2006
    Posts
    110
    Thanks
    1
    Thanked 0 Times in 0 Posts
    thanks!
    I feel like a horse's ***.
    I really appreciate your help!

  • #4
    Regular Coder ralph l mayo's Avatar
    Join Date
    Nov 2005
    Posts
    951
    Thanks
    1
    Thanked 31 Times in 29 Posts
    Don't feel bad, we're all taught that = is equality from so young it's very hard to go back. Using something like := for assignment and keeping = for equality is a far better language design decision in my humble.


  •  

    Posting Permissions

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