A
Anonymous
Guest
Right now I have a page that pulls data from a table, like so:
// get client list
$query = "SELECT * from clients ORDER BY company";
$result = mysql_db_query($database, $query, $connection) or die ("Error in
query: $query. " . mysql_error());
//interate through resultset and display
while (list($clientid, $first_name,$last_name,$company,$address,$address2,$city,$state,$zip,$phone,$fax,$cell,$date_time)=mysql_fetch_row($result))
{
echo "<div class=\"content\"><b><center>$company</center></b><br />";
if ($first_name != '') echo "$first_name ";
if ($last_name != '') echo "$last_name<br />";
if ($address != '') echo"$address<br />";
if ($address2 != '') echo"$address2<br />";
if ($city != '') echo"$city";
if ($city != '' && $state != '') echo",";
if ($state != '') echo" $state";
if ($zip != '') echo" $zip<br />";
if ($phone != '') echo"Phone: $phone<br />";
if ($fax != '') echo"Fax: $fax<br />";
if ($cell != '') echo"Cell: $cell<br />";
$datentime = date('n/j/Y g:i a',strtotime($date_time));
echo "<br />Entry Date: $datentime";
echo "</div>";
}
I would like to have a link, or button that the user can click on and change which field the data is sorted by. What is the easiest way to do this?
TIA!
// get client list
$query = "SELECT * from clients ORDER BY company";
$result = mysql_db_query($database, $query, $connection) or die ("Error in
query: $query. " . mysql_error());
//interate through resultset and display
while (list($clientid, $first_name,$last_name,$company,$address,$address2,$city,$state,$zip,$phone,$fax,$cell,$date_time)=mysql_fetch_row($result))
{
echo "<div class=\"content\"><b><center>$company</center></b><br />";
if ($first_name != '') echo "$first_name ";
if ($last_name != '') echo "$last_name<br />";
if ($address != '') echo"$address<br />";
if ($address2 != '') echo"$address2<br />";
if ($city != '') echo"$city";
if ($city != '' && $state != '') echo",";
if ($state != '') echo" $state";
if ($zip != '') echo" $zip<br />";
if ($phone != '') echo"Phone: $phone<br />";
if ($fax != '') echo"Fax: $fax<br />";
if ($cell != '') echo"Cell: $cell<br />";
$datentime = date('n/j/Y g:i a',strtotime($date_time));
echo "<br />Entry Date: $datentime";
echo "</div>";
}
I would like to have a link, or button that the user can click on and change which field the data is sorted by. What is the easiest way to do this?
TIA!