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

php - How to pass multiple values from url -

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

database - php search bar when I press submit with nothing in the search bar it shows all the data -