2017-06-29 55 views
0

嗨,我從https://www.codexworld.com/delete-multiple-records-from-mysql-in-php/得到一個教程,我發送的值id有:如何多的foreach在PHP

echo "<td align='center'><input type='checkbox' name='checked_id[]' value=" . $row['id'] . "></td>"; 

和我得到它:

if (isset($_POST['bulk_delete_submit'])) { 
    $id; 
$user_id;  

$idArr = $_POST['checked_id']; 
    foreach ($idArr as $id) { 
    echo $id; 
} 
} 

,但我想發送用戶ID太

echo "<td align='center'><input type='hidden' name='user_id[]' value=" . $row['user'] . "></td>"; 

和發送ID和用戶ID,以類刪除

$class = new manage_user_profile(); 
$class->seter_delete_user_id($id,$user_id); 

我想要獲取ID和用戶ID在foreach

感謝

+0

類似的東西:'爲($ I = 0; $ i Jeff

+0

非常感謝這個工作很好 – nazanin

回答

0

我會嘗試這樣的事:

if (isset($_POST['bulk_delete_submit'])) { 
    $id; 
$user_id;  

$idArr = $_POST['checked_id']; 
foreach ($idArr as $key=>$id) { 
     echo $id; 
     $class = new manage_user_profile(); 
     $class->seter_delete_user_id($id,$_POST['user_id'][$key]); 
    } 
}