Jump to content


This topic is now archived and is closed to further replies.


Trying to sort table results by headers...

Recommended Posts

I am trying to be able to sort a table by the different column headings. The table is the result of a search of a mysql db and I have no idea how or where to start. Any suggestions???

Thanks a lot!

This is the results page of my search where I need the sort to happen:


<table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000">
<td width="60"><b>DT_STRING</b></td>
<td width="100"><b>ACCOUNT</b></td>
<td width="30"><b>ACCOUNT_TYPE</b></td>
<td width="150"><b>CLIENT_ID</b></td>
<td width="150"><b>USER_ID</b></td>
<? $hostname = "mysql"; // The Thinkhost DB server.
$username = "root"; // The username you created for this database.
$password = "rootroot"; // The password you created for the username.
$usertable = "AUDIT"; // The name of the table you made.
$dbName = "AUDITMED"; // This is the name of the database you made.

MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable");
@mysql_select_db( "$dbName") or die( "Unable to select database");

//error message (not found message)begins
$XX = "No Record Found, to search again please close this window";

//query details table begins

$metode = $_POST['metode'];
$search = $_POST['search'];
$metode2 = $_POST['metode2'];
$search2 = $_POST['search2'];

$query = mysql_query("SELECT * FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%'");

while ($row = @mysql_fetch_array($query))
//table layout for results

print ("<tr>");
print ("<td>$variable1</td>");
print ("<td>$variable2</td>");
print ("<td>$variable3</td>");
print ("<td>$variable4</td>");
print ("<td>$variable5</td>");
print ("</tr>");
//below this is the function for no record!!
if (!$variable1)
print ("$XX");

Thanks again!

Share this post

Link to post
Share on other sites


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.