-1

This code needs a save.php file to insert data from forms.. i dont any clue on how to make a loop for the arrays.

<!-- 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>

In need of a save code

Git the code form smarttutorials.net and I need a .php file to save or insert the data from the form.. I dont know where to start. any ideas?

Juunah
  • 1
  • possible duplicate of [insert multiple rows via a php array into mysql](http://stackoverflow.com/questions/779986/insert-multiple-rows-via-a-php-array-into-mysql) – Damaged Organic Mar 08 '15 at 10:11
  • 1
    where's your code? you need to write saveStocks.php and then we can help you. Start by searching google or whatever search engine you use for "php form handling" – zeidanbm Mar 08 '15 at 10:15

1 Answers1

0

I presume your question is how could you loop through the data passed by form to savestocks.php.

In this case $_POST gives you array of the the value name pairs passed. So it could be like this:

foreach ($_POST as $key=>$value){
  .... here do you processing.....
}
Ashutosh Nigam
  • 868
  • 8
  • 27