Jump to content

KelvinMorel

New Members
  • Posts

    5
  • Joined

  • Last visited

Community Answers

  1. KelvinMorel's post in SQLSRV sort table by table header was marked as the answer   
    Done, found the way to do it with JQuery tablesorter
    <html> <head> <title>SQL Server (sqlsrv)</title> <link rel="stylesheet" href="jquery/themes/blue/style.css" type="text/css" media="print, projection, screen" /> <script type="text/javascript" src="jquery/jquery-3.2.1.js"></script> <script type="text/javascript" src="jquery/jquery.tablesorter.js"></script> <script type="text/javascript" src="jquery/jquery.tablesorter.widgets.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#myTable").tablesorter(); } ); </script> </head> <body> <div class="table-title"> <h3>DB List</h3> <?php ini_set('display_errors', 1); error_reporting(~0); include('connect.php'); ?> <form action="list.php" method="POST"> <select name="RegSelect"><option> Choose </option> <?php $query1 = "SELECT DISTINCT CountryRegionName FROM someDB ORDER BY CountryRegionName"; $stmt1 = $conn->query( $query1 ); while ($data = $stmt1->fetch(PDO::FETCH_ASSOC)){ echo '<option value="'.$data['CountryRegionName'].'">'; echo $data['CountryRegionName']; echo "</option>"; } if(empty($_POST['RegSelect'])){ $_SESSION['tower'] = ''; } else { $query2 = "SELECT BusinessEntityID, FirstName, LastName, JobTitle, PhoneNumber, PhoneNumberType, EmailAddress, AddressLine1, City, PostalCode, CountryRegionName, Status FROM someDB WHERE CountryRegionName = '".$_POST['RegSelect']."' ORDER BY JobTitle ASC"; $stmt2 = $conn->query( $query2 ); } ?> <input type="submit" value="Select Tower"> </select></br></br> </form> <table id="myTable" class="tablesorter" align="center"> <thead> <tr> <th width="91">Entity ID</th> <th width="98">Fist Name</th> <th width="198">Last Name</th> <th width="97">Job Title</th> <th width="59">Phone Number</th> <th width="71">Phone Type</th> <th width="30">Email Address</th> <th width="30">Address</th> <th width="30">City</th> <th width="30">Postal Code</th> <th width="30">Region Name</th> <th width="30">Status</th> <th width="30">Edit</th> </tr> <thead> <tbody> <?php if(empty($stmt2)){ echo ''; }else{ while ($result = $stmt2->fetch(PDO::FETCH_ASSOC)){ ?> <tr> <td><?=$result["BusinessEntityID"];?></td> <td><?=$result["FirstName"];?></td> <td><?=$result["LastName"];?></td> <td><?=$result["JobTitle"];?></td> <td><?=$result["PhoneNumber"];?></td> <td><?=$result["PhoneNumberType"];?></td> <td><?=$result["EmailAddress"];?></td> <td><?=$result["AddressLine1"];?></td> <td><?=$result["City"];?></td> <td><?=$result["PostalCode"];?></td> <td><?=$result["CountryRegionName"];?></td> <td><?=$result["Status"];?></td> <td><a href="edit_bck.php?BusinessEntityID=<?php echo $result["BusinessEntityID"];?>">Edit </a></td> </tr> <?php } } ?> </tbody> </table> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.