Sorting table data by columns and permalinks... (5 posts)

  1. Jim R
    Posted 4 years ago #

    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.

  2. esmi
    Forum Moderator
    Posted 4 years ago #

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

  3. Jim R
    Posted 4 years ago #

    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.

  4. Jim R
    Posted 4 years ago #

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

  5. Jim R
    Posted 4 years ago #

    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';

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.