多行php mysql插入

时间:2015-03-08 10:09:23

标签: javascript php arrays

此代码需要一个save.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文件来保存或插入表单中的数据..我不知道从哪里开始。任何想法?

1 个答案:

答案 0 :(得分:0)

我认为你的问题是如何将表单传递给savestocks.php的数据循环。

在这种情况下,$ _POST为您提供传递的值名称对的数组。所以它可能是这样的:

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