There was another thread started very recently (and probably many others over time) asking this same question. I believe the common solution is to simply build an array of results and process the items in that array in the order of the list of id's you have.
For example, use a query like this to get all of the rows with matching ID's:
$query = 'SELECT id, col1, col2 FROM myTable WHERE id IN (' . implode(',', $list_of_ids) . ')';
Then, store all of the results in a multi-dimensional array using the ID as the key:
$data = array();
while($row = mysql_fetch_assoc($exec))
$data[array_shift($row)] = $row;
(Note that I simply used [man]array_shift/man to get the id column and remove it from the array because I listed the id column first in the SELECT query above.)
Finally, you'd loop through your list of ordered ID's and process the data in that order, e.g.:
foreach($list_of_ids as $id) {
// process the data in $data[$id] here
}
EDIT: One alternative to the above method is to do the ordering in the query itself. To do this, however, you'd need a bunch of "CASE xx THEN 1 .... CASE yy THEN 2 ... etc." code in your ORDER BY statement. If you'd rather go down this route, then look up the "CASE" SQL syntax instead.