Query to sort by field variable in URL
Posted: Fri Jul 14, 2006 10:31 am
I'm trying to write a query that will pull all data from a table and allow me to sort the data by one of the fields, but do it within a URL. The field I want to sort by is "city" and I want the results to show two links:
1) To results.php that will display listings in only one city similar to this:
2) To results.php that will display listings in all cities except the one above.
I'm still working on different variations of this code:
Any help will be appreciated.
1) To results.php that will display listings in only one city similar to this:
Code: Select all
<a href='accommodations.php?city=Town1'>Lodging In Town1</a>I'm still working on different variations of this code:
Code: Select all
$query = "SELECT * FROM lodging";
$result = mysql_query($query) or die("Error: " . mysql_error());
while($row = mysql_fetch_row($result)){
echo("<ul><li><a href='accommodations.php?city=Town1'>Lodging In Town1</a></li>
<li><a href='accommodations.php?city!=Town1'>Lodging In other Towns</a></li>
</ul>");
}