I want to be able to sort my query tabe by asc then when I click on the link I want it to sort by desc can someone help me with the code. Here is what I have.
<?php mysql_connect("localhost", "my_username", "my_password") or die(mysql_error()); mysql_select_db("websited_Contacts") or die(mysql_error()); if ($_REQUEST['action'] == "del") { $id = intval($_REQUEST['id']); mysql_query("DELETE FROM Contacts WHERE id='$id'"); echo " Deleted {$_REQUEST['acc']} From The contacts List"; } if ($_REQUEST['action'] == "sort") { $col=$_REQUEST['col']; $result = mysql_query("SELECT * FROM `Contacts` ORDER BY `Contacts`.`$col` ASC") or die(mysql_error()); } else { $col=$_REQUEST['col']; $result = mysql_query("SELECT * FROM `Contacts` ORDER BY `Contacts`.`$col` DESC")or die(mysql_error()); } echo "
"; echo "Company Name"; echo " | "; echo "Full Business Address"; echo " | "; echo "Current Website Address"; echo " | "; echo "Phone Humber"; echo " | "; echo "Email Address"; echo " | "; echo "Describe Your Business Needs"; echo " | "; echo "Remove?"; echo " |
---|---|---|---|---|---|---|
"; echo $row['field_1']; echo " | "; echo $row['field_2']; echo " | "; echo $row['field_3']; echo " | "; echo $row['field_4']; echo " | "; echo $row['field_5']; echo " | "; echo $row['field_6']; echo " | "; echo "delete"; echo " |