Results 1 to 3 of 3

Thread: Organise by user defined method

  1. #1
    Join Date
    Mar 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Organise by user defined method

    Below is the code I have used to output a table (with headers). This is working fine (obviously I have removed the call to the database as this isn't necessary to show)

    I was hoping somebody could help me, I want this to be able to be ordered by any of the headers and with a simple method of doing so (ideally clicking on the header, but don't know if this is possible or by a dropdown menu on the same page)

    I'm relatively new to php (having come from mainly ASP & ASP.NET background).
    Please ignore my sloppy code but it worked for what I needed it for first day!

    Thanks for any help you can give me!


    PHP Code:

    $result 
    mysql_query("SELECT * from student");

    //Table starting tag and header cells
    echo "<table border='1'><tr><th>ID</th><th>Name</th><th>Surname</th><th>Gender</th><th>Date Of Birth</th><th>Telephone</th><th>Request</th><th>Agent</th><th>Host Family ID</th><th>Airport Name</th><th>Airport Arrival Date</th><th>Airport Arrival Time</th><th>Added Details</th></tr>";
    while(
    $row mysql_fetch_array($result))
    {
        
    //Display the results in different cells
        
    echo "<tr><td>" $row['sid'] . "</td><td>" $row['sname'] . "</td><td>" $row['ssurname'] . "</td><td>" $row['sgender'] . "</td><td>" $row['sdob'] . "</td><td>" $row['stelephone'] . "</td><td>" $row['srequest'] . "</td><td>" $row['sagent'] . "</td><td>" $row['shostfamilyid'] . "</td><td>" $row['safairport'] . "</td><td>" $row['safdate'] . "</td><td>" $row['saftime'] . "</td><td>" $row['details'] . "</td></tr>";
    }
    //Table closing tag
    echo "</table>"
    Last edited by traq; 03-28-2013 at 03:09 AM. Reason: please use [PHP] tags to post php code

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    2,040
    Thanks
    16
    Thanked 316 Times in 314 Posts
    Blog Entries
    14

    Default

    Maybe a JavaScript solution would suit your needs. I've used this jQuery tablesorter plugin in a few projects: http://tablesorter.com/docs/ otherwise there's plenty of choice here: http://www.tripwiremagazine.com/2012...t-plugins.html
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  3. #3
    Join Date
    Mar 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Beverleyh View Post
    Maybe a JavaScript solution would suit your needs. I've used this jQuery tablesorter plugin in a few projects: http://tablesorter.com/docs/ otherwise there's plenty of choice here: http://www.tripwiremagazine.com/2012...t-plugins.html
    Thanks Beverley, I'll definitely try these out. I tried the tablesorter quickly but it may be my stupid brain or something else but it's not working for me. I'm sure one of what you showed me will work! Appreciate it!

Similar Threads

  1. what's the best relationship method for a user table with app tables
    By sniperman in forum MySQL and other databases
    Replies: 1
    Last Post: 01-04-2011, 07:09 PM
  2. Making Read-only property in a user-defined JS object
    By codeexploiter in forum JavaScript
    Replies: 6
    Last Post: 03-12-2009, 04:47 PM
  3. Partly User defined link
    By Bacchus in forum JavaScript
    Replies: 1
    Last Post: 08-31-2006, 01:48 PM
  4. DHTML window - user defined
    By orphy in forum Dynamic Drive scripts help
    Replies: 10
    Last Post: 04-12-2006, 04:18 AM
  5. Javascript User Defined Settings Question
    By echotheory in forum JavaScript
    Replies: 1
    Last Post: 09-28-2004, 05:27 AM

Bookmarks

Posting Permissions

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