I am currently working on a project where I need to sort my MYSQL query results by different categories. How ever the code does not seem to be working properly and I spend too much time on it already.
So here is the code:
[PHP]
if (isset($_GET['sortby'])){$sort = $_GET['sortby'];}
else $sort = '';
$query = "SELECT * FROM list WHERE county = '$counties[$x]' order by '$sort' ";
$db->query($query );
[/PHP]
When I view the results I dont the order I want, the order I posted $_GET
how ever when I let the query be lets say "bandwidth"
[PHP] $query = "SELECT * FROM list WHERE county = '$counties[$x]' order by bandwidth ";[/PHP]
it works.
can you help me where am I going wrong.
So here is the code:
[PHP]
if (isset($_GET['sortby'])){$sort = $_GET['sortby'];}
else $sort = '';
$query = "SELECT * FROM list WHERE county = '$counties[$x]' order by '$sort' ";
$db->query($query );
[/PHP]
When I view the results I dont the order I want, the order I posted $_GET
how ever when I let the query be lets say "bandwidth"
[PHP] $query = "SELECT * FROM list WHERE county = '$counties[$x]' order by bandwidth ";[/PHP]
it works.
can you help me where am I going wrong.
Comment