SQL:
SELECT question,alt_1,alt_2,alt_3,alt_4 FROM questions WHERE id IN ('12','2','32','23')
PHP:
while ($questions = mysql_fetch_array($game)){
echo "$questions[question]";
}
I want the rows to be printed in the order the values are sent to sql: 12 - 2 - 32 - 23.
But fetch_array/sql(?) seems to sort the values so the order becomes the following: 2 - 12 - 23 - 32 (starts with the lowest number..)
Is there any way to stop the array from being sorted by numbers!?
USE FIND_IN_SET
SELECT question,alt_1,alt_2,alt_3,alt_4
FROM questions
WHERE id IN ('12','2','32','23')
ORDER BY FIND_IN_SET(id, '12,2,32,23')
Note FIND_IN_SET(id, '12,2,32,23') 12,2 without space
FIND_IN_SET(field, 'val1,val2')
Try yhis,
" ORDER BY FIELD(id'12','2','32','23')"
SQL: "SELECT question,alt_1,alt_2,alt_3,alt_4 FROM questions WHERE id IN
('12','2','32','23') ORDER BY FIELD(id'12','2','32','23')"
while($questions = mysql_fetch_array($game)){
echo "$questions[question]";
}