Support » Plugins » Hacks » Sorting table data by columns and permalinks…

  • I have a table of data echoing to a PHP page, which I put in the WP page via INCLUDE. Before I moved over to WP, the User could sort that table by whichever column they wanted. The code to do that was:

    <td width="21%"><b><a href="/teams/coaches.php?sortby=coachLast">Name</a></b></td>
            <td width="23%"><b><a href="/teams/?sortby=school">High School</a></b></td>
            <td width="13%"><b><a href="/teams/coaches.php?sortby=sectional">Sectional</a></b></td>
            <td width="8%"><b><a href="/teams/coaches.php?sortby=class">Class</a></b></td>
            <td width="35%"><b><a href="/teams/coaches.php?sortby=email">Email</a></b></td>

    It’s not working within WP. I’m assuming it’s a permalink issue, and I have tried to change the code to match what the permalink produces. Is it possible when the User clicks the link, it’s not passing the variable after the ‘?’ to the next page load?

    I’m not strong enough with PHP and WP to know how it really works.

Viewing 4 replies - 1 through 4 (of 4 total)
  • esmi


    Forum Moderator

    You’d need to replace the first part of each url with the full url (permalink) for the current WordPress Page.

    That didn’t work. It produced the same thing. It takes me right back to the page but ignores the ?sortby=coachLast (for example).

    That coaches.php above is the name of the INCLUDE file. It’s not passing the variable is the only thing I can tell.

    I set the permalink to not use the trailing slash, but it still didn’t work.

    Here is the condition I’m using the set the sortby code.

    if (!isset($_GET['sortby'])) {
    $sortby = "sectional";
    $query = 'SELECT * FROM hhr_schools ORDER BY '. $sortby .' ASC';
    else {
    $sortby = $_GET['sortby'];
    $query = 'SELECT * FROM hhr_schools ORDER BY '. $sortby .' ASC, nameLast ASC';
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Sorting table data by columns and permalinks…’ is closed to new replies.