php - how to get values of array out -


i have array

$pv->orderrecordsarray = array();   foreach($order->records $i=>$orderrecord){  $pv->orderrecordsarray[] = $orderrecord->orderrecordid;           }  // print_r($pv->orderrecordsarray) example // shows array ( [0] => 46839 [1] => 46840 [2] => 46841 ) 

i need use array values above in sql statement below.

$sql = "     select      *                              table1                         orderrecordid in (46741, 46742)           "; 

so infront of in want $pv->orderrecordsarray results.

thanks

you can use implode generate such list:

$sql = "select *         table1         orderrecordid in (" . implode(', ', $pv->orderrecordsarray) . ")"; 

but should consider subquery or join of tables.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -