mysql: $result = mysql_query("SELECT * FROM properties Where p_id in(1,2,3,4) order by instr('1,2,3,4',p_id) ");