我建立我在哪裏使用jQuery插件數據表一個Laravel 5應用填充輸入。在數據表中,每行有3個輸入字段。我想要做的是插入所有填充的行輸入。在每一行中,您必須填寫所有3個輸入,以便將數據發佈到數據庫中。 (數據庫是sql服務器。)我嘗試了一些東西,但它不工作。以下是我在控制器存儲方法已經試過:插入到數據庫中只有一個html表
$dates = $request->get('month');
$values = $request->get('value');
$comments = $request->get('comment');
$reports = []; // this will keep what we input in our DB
/*if(!empty($row['month']) && !empty($row['value']) && !empty($row['comment'])){
foreach($row as $rows){
$index = +1;
}
}*/
if(!empty($dates) && !empty($values)){
for($i = 0; $i < count($dates); $i++)
{
//here i am dividing month and year
$date = explode('-', $dates[$i]);
$year = $date[0];
$month = $date[1]; // <-- line 75
$reports[] = Reports::create([
'month' => $month,
'year' => $year,
'value' => $values[$i],
'comment' => $comments[$i]
]);
}
}
return $reports;
這引發了我的錯誤,但:
ErrorException in ReportController.php line 75:
Undefined offset: 1
我搜索它,它說,我是傳遞一個數組而不是一個字符串。
這裏是堆棧跟蹤(的一部分):
at HandleExceptions->handleError('8', 'Undefined offset: 1', 'E:\socgen\soc-gen\app\Http\Controllers\ReportController.php', '75', array('request' => object(Request), 'dates' => array('2015-06', '2015-02', ''), 'values' => array('369', '22223', ''), 'comments' => array('878', '5466', ''), 'reports' => array(object(Reports)), 'i' => '1', 'date' => array(''), 'year' => '', 'month' => '06')) in ReportController.php line 75
任何幫助或暗示表示讚賞
你在第75行的代碼是什麼 –
'$ row'是什麼?它來自哪裏? – itachi
@itachi對不起,這是一個我早些時候做的測試。它應該已經在評論這裏 – xhulio