2016-09-14 71 views
-1

我有陣列輸出,我想用出從數據庫中獲得另一個輸出這是我的查詢:循環選擇查詢裏面的foreach PHP PDO

$access_array = array(2,3,4); 

foreach($access_array as $val){ 
     $index_erp = "id,name,alias,images";  
     $where_erp = "WHERE glb_pmstr_app_id = '2' and id = '".$val."'"; 
     $RES_SQL = $this->SQL_Query->__Select($index_erp,$tbl_app_feature,null,$where_erp,null,null,SQL_FETCHALL); 
} 

和我應該從$結果獲得3行RES_SQL,但我只從數據庫中獲得1行。

如何解決這個問題?

+0

我沒有看到任何輸出數組 – rapidoodle

回答

0
$access_array = array(2,3,4); 
$output = array(); 

foreach($access_array as $val){ 
    $index_erp = "id,name,alias,images";  
    $where_erp = "WHERE glb_pmstr_app_id = '2' and id = '".$val."'"; 
    $RES_SQL = $this->SQL_Query->__Select($index_erp,$tbl_app_feature,null,$where_erp,null,null,SQL_FETCHALL); 
    $ouput[] = $RES_SQL; 
} 

這是你想要做的嗎?

+0

謝謝你多數民衆贊成,爲我工作.. –

+0

upvote將不勝感激! – rapidoodle

+0

sory,我不能放棄,因爲我的名聲;( –