Jump to content


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


Need help fixing 'sort' script

Recommended Posts

I have this script to hopefully sort by the headers in my results table, but when I click on the headers it goes to the error page that says there is no data to display. Any ideas?

Thanks a lot!


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000">
<td width="60"><b><a href="?sortby=DT_STRING">DT_STRING</a></b></td>
<td width="100"><b><a href="?sortby=ACCOUNT">ACCOUNT</a></b></td>
<td width="30"><b><a href="?sortby=ACCOUNT_TYPE">ACCOUNT_TYPE</a></b></td>
<td width="150"><b><a href="?sortby=CLIENT_ID">CLIENT_ID</a></b></td>
<td width="150"><b><a href="?sortby=USER_ID">USER_ID</a></b></td>
<? $hostname = "mysql"; // The Thinkhost DB server.
$username = ""; // The username you created for this database.
$password = ""; // 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";

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

$sortvalues = array("DT_STRING", "ACCOUNT", "ACCOUNT_TYPE", "CLIENT_ID", "USER_ID");

if(isset($_GET['sortby']) && in_array($_GET['sortby'], $sortvalues))
$sortby = $_GET['sortby'];

$sortby = "DT_STRING";

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

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 for any advice!

Share this post

Link to post
Share on other sites
Please do not post your problem in different forums. You already have the same thread [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=90303\" target=\"_blank\"]here[/a] which I am trying to help you on.

Topic closed

Share this post

Link to post
Share on other sites
This topic is now closed to further replies.


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.