php - SQL ORDER BY FIELD() use array -
php - SQL ORDER BY FIELD() use array -
hello im wondering if there way me pass array
order field()
function, have like
<?php $array = (5, 8, 7, 10); $query = "select * table order field(id,".$array.")"; ?>
is possible? how accomplish this?
you can utilize implode
create comma separated list:
<?php $array = array(5, 8, 7, 10); $query = "select * table order field(id,".implode( $array, ',' ).")"; echo( $query ); ?>
outputs:
select * table order field(id,5,8,7,10)
php sql
Comments
Post a Comment