0
試圖從textarea的行添加到mysql數據庫,只是最後一排正確插入所有其他行插入空
$model = 'MacBook Pro';
$lines = explode("\n", $textarea);
foreach ($lines as $model_number) {
$rows_affected = $wpdb->insert($table_name, array('model'=>$model, 'model_number'=>$model_number));
的var_dump($ MODEL_NUMBER)返回:
string(6) "A4348 " string(6) "A3412 " string(5) "A8495"
MySQL的行:
+----+-------------+----------------------------------+
|
|
| 87 | MacBook Pro | A8495 |
+----+-------------+----------------------------------+