Jump to content

Need help fixing 'sort' script


ccutla

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!

php:


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

<center>
<table border="1" cellpadding="5" cellspacing="0" bordercolor="#000000">
<tr>
<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>
</tr>
<tr>
<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'];
}
else
{

$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))
{
$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 for any advice!
Link to comment
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
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.