如何在mysql数据库php中以表单形式添加多个数组?
我有一个表单,用于获取产品的数据库条目。我在一个表单中添加了多行产品,我需要数据库插入方面的帮助。 我希望在一行中添加数据,并且我有多个数组如何在mysql数据库php中以表单形式添加多个数组?,php,mysql,arrays,Php,Mysql,Arrays,我有一个表单,用于获取产品的数据库条目。我在一个表单中添加了多行产品,我需要数据库插入方面的帮助。 我希望在一行中添加数据,并且我有多个数组 <form id='students' method='post' name='students' action='add- <div class="table-responsive"> <table class="table"> <tr>
<form id='students' method='post' name='students' action='add-
<div class="table-responsive">
<table class="table">
<tr>
<th><input class='check_all' type='checkbox' onclick="select_all()"/></th>
<th>S. No</th>
<th>BarCode</th>
<th>HSN</th>
<th>Product Name</th>
<th>MRP</th>
<th>CGST</th>
<th>SGST</th>
</tr>
<tr>
<td><input type='checkbox' class='case'/></td>
<td><span name='snum[]' id='snum'>1.</span></td>
<td><input class="form-control" type='text' id='countryname_1' name='countryname[]'/></td>
<td><input class="form-control" type='text' id='country_no_1' name='country_no[]'/></td>
<td><input class="form-control" type='text' id='phone_code_1' name='phone_code[]'/></td>
<td><input class="form-control" type='text' id='country_code_1' name='country_code[]'/> </td>
<td><input class="form-control" type='text' id='cgst_1' name='cgst1[]'/> </td>
<td><input class="form-control" type='text' id='sgst_1' name='sgst1[]'/> </td>
</tr>
</table>
<input type="submit" value="submit">
<button type="button" class='btn btn-danger delete'>- Delete</button>
<button type="button" class='btn btn-success addmore'>+ Add More</button>
</div>
</form>
如果我正确理解了您的问题,您正在尝试在数据库中存储数组。这本身是不可能的,但在获取数据时可以使用serialize()函数和unserialize()
请稍作努力您的表格结构和所需输出是什么?是否希望每个产品索引有一行?它们都是逗号分隔的吗?等等。到目前为止您尝试了什么?您的表单是错误的----@kchason-是的,我需要每个产品索引的行,我尝试了pair()和基本方法来存储数组,但我仅限于添加同名数组,但我这里有5个不同的名称数组,这给我带来了一个问题。@B001-谢谢,但我放置表格只是为了对ArrayShanks michal有一个大致的了解-你能在细节上提供帮助吗,听起来它会解决问题