Originally posted by gljones
Hi,
I'm able to query a table and display the results in a particular order, e.g. by City:
$query = "SELECT * FROM table where state = '$state' ORDER BY city asc";
i want to order by whether a certain field has something in it, so that i can order the returned list by those that have an image in the image field and also by 'city'.
thanks for any help.
$query = "SELECT * FROM table where state = '$state' and imagefield=1 ORDER BY city asc";
(These query give you records that have he field 'imagefield' to 1 ordered by city)
or
$query = "SELECT * FROM table where state = '$state' ORDER BY imagefield,city asc";
(These query order all records first in imagefield then in city field!)
Ex
ID|CITY|IMFIELD
1|aaaaa|1
2|aaaab|2
3|aaaac|1
You will have these sequence: 1,3,2