I am pulling information that has cities attached to it and i would like the information to be in a order where it shows the current city first, then cities in an order by distance from the city searched. I have the cities in the order that i would want them shown in an array called $nearby_city_array. Is there any way that I could pull the data, in order, according to where it shows up in my array?
$query = "SELECT
username, city, state
FROM
...
WHERE
city = '" . $city . "'
state = '" . $state . "'
ORDER BY " . $nearby_city_array . ";
$result = mysql_query($query, $db) or die(mysql_error($db));
Any ideas would be great thanks.
While you have found a better solution, i.e. one using the information stored in the database, someone else visiting this question might search for a solution for the original question.
This is the idea:
This creates a temporary table containing the data in the order as they are in the list. If you join this table to your original query and order the result by the row ID in the temp table, you get exactly what you want.
As said, if you can omit this list and use data which are already present in the DB, it is better.