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 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2002
    Location
    Cape Town, South Africa
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to modify columns after they have been set?

    I want to enable the user to change a table gnereted by a sql query in the following ways.

    1) To re-order the table according to a particular column by clicking on a column header which is a hyperlink.

    So say there is a table generated by sql like this:

    Code:
    SELECT id, name, age FROM cust
    if the user clicks on 'name' the table, should be changed to reflect the result of:

    Code:
    SELECT id, name, age FROM cust ORDER BY name
    (and the same for id, age etc).

    2) I want to allow the user to select columns to show/hide.
    Say the orginal query is:

    Code:
    SELECT id, name, age FROM cust
    Then I want checkboxes for each of the attributes in the select list and allow the user to select only the columns that they want to see (before resubmitting the form)

    Thanks in advance for any help!

  • #2
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    Well assuming your using php try this:
    Code:
    $sql='';
    if(isset($_GET['order'])) {
      $sql = "SELECT id, name, age FROM cust ORDER BY $_GET[order]";
    }
    else {
      $sql="SELECT id, name, age FROM cust";
    }
    then in your databse connection do
    Code:
    mysql_query($sql,$linkID);
    where $linkID=is your database handle
    in your HTML you'll need something like
    <a href="my_php.php?order=name">Name</a>

  • #3
    New Coder
    Join Date
    Aug 2002
    Location
    Cape Town, South Africa
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the help bcarl314 . I tried it and it worked 100% !!

    Thanks again!


  •  

    Posting Permissions

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