的我從數據庫中檢索某些數據的價值,把它變成一個表視圖如何得到多個複選框
if (isset($_POST['user_id'])) {
foreach ($_POST['user_id'] as $value) {
$user = User::find($value);
$id = Some::create([
'user_id' => $user->id,
'user_email' => $user->email,
'user_name' => $user->name,
'location' => $user->location,
'user_phone' => $user->phone,
'created_at' => \Carbon\Carbon::now()->subDays(3),
]);
$id->update(['created_at' => \Carbon\Carbon::now()->subDays(3)]);
$id->created_at = \Carbon\Carbon::now()->subDays(3);
$id->save();
if ($id)
{
// delete user from PH table
$deleteUser = ProvideHelp::where('user_id', $id->user_id)->delete();
if ($deleteUser) {
return redirect('home')->with('success', 'Your Addition was successful');
}
}
}
}
return redirect('home')->with('error', 'Inter Error Please try again Later');
循環只適用於第一個數據和休息不工作。我想使用每個循環的值來查詢數據庫。只有第一個查詢有效 - 第二個或第三個查詢不起作用。
存在多個用戶標識並且其索引爲'userid []' – dagogodboss
存在多個用戶標識並且其索引爲'userid []' – dagogodboss