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
Post a Comment