ccutla Posted April 5, 2006 Share Posted April 5, 2006 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:php:<center><table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000"><tr><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></tr><tr><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)) { $variable1=$row["DT_STRING"];$variable2=$row["ACCOUNT"]; $variable3=$row["ACCOUNT_TYPE"]; $variable4=$row["CLIENT_ID"];$variable5=$row["USER_ID"];//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");} //end ?></table></center>Thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.