我在 mysql 中有一个表,其中包含字段 Seat_id(pk),bus_id,seat_number,row_name,col_name
现在我必须将值插入到此 php 代码的每个字段中。
<?php
for($i=1;$i<=10;$i++)
{
echo "<tr>";
for($j=1;$j<=4;$j++)
{
echo "<td>
<input type=\"text\" value=\"\" style=\"width:20px\" name=\"seat_no[]\" />
<input type=\"text\" style=\"width:20px\" value=\"$i\" name=\"row_name[]\" />
<input type=\"text\" value=\"$j\" style=\"width:20px\" name=\"col_name[]\" />
</td>";
}
echo "</tr>";
}
?>
现在的问题是如何循环将每一行插入到mysql中。 预先感谢您。
最佳答案
试试这个:
INSERT INTO table_name (bus_id, seat_number,row_name,col_name) VALUES
(203, 5,'something','something'),
(203, 4,'something','something'),
(203, 7,'something','something');
关于mysql - 使用循环pdo插入mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30660065/