mysql - How to match a word from string and retrieve data in SQL Query and PHP? -


i have mysql table this

brand  -------- honda sozuki oddi . . . 

now there dynamic array in php :

$brand = ["sozuki","honda"] 

the question how retrieve data matches word in above array. tried :

$qry = 'select * brand brand '% $brand[0] %' , '% $brand[1] %'; 

it works fine if have no specific length of array, can dynamic array. solution appreciated thanks

try

$qry = "select * brand brand "; $i=1; $count = count($brand);  foreach($brand $v) {   $a = ($i < $count ? 'and' : '');   $qry .=  " '% $v %'  $a ";   $i++; } echo $qry; 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -