ivor ivor - 4 years ago 108
MySQL Question

how to select multiple ids using mysqli and php with same sorting

I tried to us IN to call multiple ids.. but the arrangement of ids are not the same..

here's my sample code:

$sample = "1,3,2,4,5";
$sql_top = "SELECT * FROM team_member WHERE pgs_team_member_id IN ($sample)";


the output that i get:
1
2
3
4

the out that want to get:
1
3
2
4
5

Answer Source

You can try order by, like this:

order by field(pgs_team_member_id, $ids);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download