Results 1 to 2 of 2

Thread: looking for help to make the table headers selectable

  1. #1
    Join Date
    Nov 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default looking for help to make the table headers selectable

    Hi

    I need help to make my table headers selectable so that when i click on any of the column headers it will be sorted as in a - z of high to low or vise versa
    here is my code so far
    Code:
    <?php 
    include_once 'index.php';
    ?>
    <!DOCTYPE html>
    <html>
    <head>
    	<title>Phonebook</title>
    	<link href="style.css" rel="stylesheet" type="text/css" />
    		    <style type="text/css">
    	
    body {
        background-image: url("background-wallpapers-19.jpg");
        
    	
    }
    </style>
    <script type="text/javascript">
    function ConfirmDelete(){
    	var d = confirm('Do you really want to delete data?');
    	if(d == false){
    		return false;
    	}
    }
    </script>
    </head>
    <body>
    <div class="wrapper">
    <div class="content" >
    <?php include 'header.php'; ?><br/>
    <div style="margin-bottom: 5px;">
    <form method="POST" action="index.php">
        <input type="text" id="searchText" name="searchText" style="width:300px"/>
        <input type="hidden" name="action_type" value="search"/>
        <input type="submit" value="Search">
    </form>
    </div>
    <div style="max-height: 350px; overflow:auto;">
    <table id="content" class="pbtable">
        <thead>
            <tr>
                <th>
                    Name
                </td>
                <th>
                    Contact #
                </th>
                <th>
                    Res. Address
                </th>
                <th>
                    Company
                </th>
                <th>
                    Company Address
                </th>
                <th></th><th></th>
            </tr>
        </thead>
        <tbody>
            <?php foreach($contact_list as $contact) : ?>
                <tr>
                    <td>
                        <?php echo $contact["contact_name"]; ?>
                    </td>
                    <td>
                        <?php echo $contact["contact_no"]; ?>
                    </td>
                    <td>
                        <?php echo $contact["residential_address"]; ?>
                    </td>
                    <td>
                        <?php echo $contact["company"]; ?>
                    </td>
                    <td>
                        <?php echo $contact["company_address"]; ?>
                    </td>
                    <td>
                        <form method="post" action="index.php">
                            <input type="hidden" name="ci"
                            value="<?php echo $contact["contact_id"]; ?>" />
                            <input type="hidden" name="action" value="edit" />
                            <input type="submit" value="Edit" />
                        </form> 
                    </td>
                    <td>
                        <form method="POST" action="index.php"
                        onSubmit="return ConfirmDelete();">
                            <input type="hidden" name="ci"
                            value="<?php echo $contact["contact_id"]; ?>" />
                            <input type="hidden" name="action" value="delete" />
                            <input type="submit" value="Delete" />
                        </form>
                    </td>
                <tr>
            <?php endforeach; ?>
        </tbody>
    </table>
    </div>
    <br/>
    <a href="update.php" class="link-btn">Add Contact</a>
    </div>
    </div>
    </body>
    </html>


    thanks in advance
    Last edited by Beverleyh; 11-27-2014 at 06:13 AM. Reason: Formatting

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    What have you tried already? There are loads of options on Google https://www.google.com/search?q=sort...ble&gws_rd=ssl Try a few out and see which ones you like.
    Last edited by Beverleyh; 11-27-2014 at 05:52 PM. Reason: Fixed predictive text replacements
    Focus on Function Web Design
    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

Similar Threads

  1. Replies: 1
    Last Post: 03-20-2014, 11:22 AM
  2. Table Headers
    By Austin Klei in forum Looking for such a script or service
    Replies: 3
    Last Post: 03-08-2010, 09:18 AM
  3. Scrolling Table Headers ?!?!
    By Conc06 in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 12-13-2006, 03:02 PM
  4. Non-selectable text??
    By tacbob in forum HTML
    Replies: 2
    Last Post: 11-15-2006, 10:11 PM
  5. Selectable CSS Text Layers
    By macdaddy in forum JavaScript
    Replies: 1
    Last Post: 11-22-2004, 01:33 PM

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
  •