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

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -