多行 PHP MySQL 插入


multiple row php mysql insert

这段代码需要一个保存.php文件来插入表单中的数据。 我不知道如何为数组制作循环。

<!-- Begin page content -->
<div class="container content">
    <div class='row'>
        <div class='col-xs-12 col-sm-12 col-md-12 col-lg-12'>
            <table class="table table-bordered table-hover">
                <thead>
                    <tr>
                        <th width="2%"><input id="check_all" class="formcontrol" type="checkbox"/></th>
                        <th width="15%">Model Code</th>
                        <th width="30%">Brand</th>
                        <th width="30%">Description</th>
                        <th width="15%">Model Num</th>
          <th width="15%">Serial Number</th>
          <th width="30%">Color</th>
          <th width="40%">Unit Cost</th>
          <th width="15%">Selling Price</th>
          <th width="25%">Interest Rate</th>
          <!-- 
          ITEM NO/product Code - model code
          ITEM NAME/product Name - brand
          PRICE - description
          QUANTITY - modelnum
           -->
                    </tr>
                </thead>
        <form id="SignupForm" method="post" action="saveStocks.php">
                <tbody>
                    <tr>
            <td><input class="case" type="checkbox"/></td>
            <td><input type="text" data-type="modelCode" name="modelCode[]" id="modelCode_1" class="form-control autocomplete_txt" autocomplete="off"></td>
            <td><input type="text" data-type="brand" name="brand[]" id="brand_1" class="form-control autocomplete_txt" autocomplete="off"></td>
            <td><input type="text" name="description[]" id="description_1" class="form-control changesNo" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>
            <td><input type="number" name="modelNum[]" id="modelNum_1" class="form-control changesNo" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>
            <td><input type="number" name="srp[]" id="srp_1" class="form-control changesNo" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>
            <td><input type="number" name="color[]" id="color_1" class="form-control changesNo" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>
            <td><input type="number" name="untiCost[]" id="unitCost_1" class="form-control changesNo" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>
            <td><input type="number" name="serialNumber[]" id="serialNumber_1" class="form-control changesNo" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>
            <td><select type="number" name="intRate[]" id="intRate_1" class="form-control changesNo" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;">
                <option></option>
                <option value="1">0.01</option>
                <option value="2">0.05</option>
                </select></td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class='row'>
        <div class='col-xs-12 col-sm-3 col-md-3 col-lg-3'>
            <button class="btn btn-danger delete" type="button">- Delete</button>
            <button class="btn btn-success addmore" type="button">+ Add More</button>
       </div>
       <input type="submit" id="SaveAccount" value="Save Stocks">
        <div class='col-xs-12 col-sm-offset-4 col-md-offset-4 col-lg-offset-4 col-sm-5 col-md-5 col-lg-5'>
        </div>
    </div>  
</div>
<h2>&nbsp;</h2>

<script src="js/jquery.min.js"></script>
<script src="js/jquery-ui.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-datepicker.js"></script>
<script src="js/auto.js"></script>

需要保存代码

Git 代码表单 smarttutorials.net,我需要一个.php文件来保存或插入表单中的数据。我不知道从哪里开始。有什么想法吗?

我想你的问题是你如何循环通过表单传递的数据来保存股票.php。

在本例中,$_POST 为您提供传递的值名称对的数组。所以可能是这样的:

foreach ($_POST as $key=>$value){
  .... here do you processing.....
}