php - storing multiple static data into database -


i have table these columns (database)

like http://netelity.com/table.jpg.

and have static form through user define installments. static 24 input boxes there this

<form name="installment"  method="post" action="" enctype="multipart/form-data" onsubmit="return validate()">     <table id="dt_hscroll" class="table table-striped">         <thead>             <tr>                 <th>sl no.</th>                 <th>amount</th>                 <th>due date</th>             </tr>             <tr>                 <td> 1. </td>                 <td>                     <input type="text" name="installment1" id="installment" class="span4" value="0" />                 </td>                 <td>                     <input type="text" name="due_date1" class="tcal span4" value="<?php //echo date("y-m-d"); ?>" />                 </td>             </tr>             <tr>                 <td> 2. </td>                 <td>                     <input type="text" name="installment2" id="installment" class="span4" value="0" />                 </td>                 <td>                     <input type="text" name="due_date2" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 3. </td>                 <td>                     <input type="text" name="installment3" id="installment" class="span4" value="0" />                 </td>                 <td>                  <input type="text" name="due_date3" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 4. </td>                 <td>                     <input type="text" name="installment4" id="installment" class="span4" value="0" />                 </td>                 <td>                  <input type="text" name="due_date4" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 5. </td>                 <td>                     <input type="text" name="installment5" id="installment" class="span4" value="0" />                 </td>                 <td>                     <input type="text" name="due_date5" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 6. </td>                 <td>                     <input type="text" name="installment6" id="installment" class="span4" value="0" />                 </td>                 <td>                     <input type="text" name="due_date6" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 7. </td>                 <td>                     <input type="text" name="installment7" id="installment" class="span4" value="0" />                 </td>                 <td>                     <input type="text" name="due_date7" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 8. </td>                 <td>                     <input type="text" name="installment8" id="installment" class="span4" value="0" />                 </td>                 <td>                     <input type="text" name="due_date8" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 9. </td>                 <td>                     <input type="text" name="installment9" id="installment" class="span4" value="0" />                 </td>                 <td>                     <input type="text" name="due_date9" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 10. </td>                 <td>                     <input type="text" name="installment10" id="installment" class="span4" value="0" />                 </td>                 <td>                 <input type="text" name="due_date10" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 11. </td>                 <td>                     <input type="text" name="installment11" id="installment" class="span4" value="0" />                 </td>                 <td>                 <input type="text" name="due_date11" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 12. </td>                 <td>                     <input type="text" name="installment12" id="installment" class="span4" value="0" />                 </td>                 <td>                 <input type="text" name="due_date12" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 13. </td>                 <td>                     <input type="text" name="installment13" id="installment" class="span4" value="0" />                 </td>                 <td>                 <input type="text" name="due_date13" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 14. </td>                 <td>                     <input type="text" name="installment14" id="installment" class="span4" value="0" />                 </td>                 <td>                 <input type="text" name="due_date14" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 15. </td>                 <td>                     <input type="text" name="installment15" id="installment" class="span4" value="0" />                 </td>                 <td>                 <input type="text" name="due_date15" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 16. </td>                 <td>                     <input type="text" name="installment16" id="installment" class="span4" value="0" />                 </td>                 <td>                 <input type="text" name="due_date16" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 17. </td>                 <td>                     <input type="text" name="installment17" id="installment" class="span4" value="0" />                 </td>                 <td>                 <input type="text" name="due_date10" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 18. </td>                 <td>                     <input type="text" name="installment18" id="installment" class="span4" value="0" />                 </td>                 <td>                 <input type="text" name="due_date18" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 19. </td>                 <td>                     <input type="text" name="installment19" id="installment" class="span4" value="0" />                 </td>                 <td>                 <input type="text" name="due_date19" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 20. </td>                 <td>                     <input type="text" name="installment20" id="installment" class="span4" value="0" />                 </td>                 <td>                 <input type="text" name="due_date20" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 21. </td>                 <td>                     <input type="text" name="installment21" id="installment" class="span4" value="0" />                 </td>                 <td>                 <input type="text" name="due_date21" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 22. </td>                 <td>                     <input type="text" name="installment22" id="installment" class="span4" value="0" />                 </td>                 <td>                 <input type="text" name="due_date22" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 23. </td>                 <td>                     <input type="text" name="installment23" id="installment" class="span4" value="0" />                 </td>                 <td>                 <input type="text" name="due_date23" class="tcal span4" />                 </td>             </tr>             <tr>                 <td> 24. </td>                 <td>                     <input type="text" name="installment24" id="installment" class="span4" value="0" />                 </td>                 <td>                 <input type="text" name="due_date24" class="tcal span4" />                 </td>             </tr>             <tr>                 <td></td>                 <td>                     <input type="submit"  name="save" id="save" value="save" class="btn btn-info span3"   />                     <input type="hidden" readonly="readonly" name="roll_no" value="<?php echo $roll_no; ?>" class="span5" />                 </td>                 <td></td>             </tr>         </thead>     </table> </form> 

here not getting how store in table. 24 inputs not mandatory. if user fills 2 should store in database table.

i tried this

    if(isset($_post['save'])) { $roll_no =  $_post['roll_no']; $ins_amt1 = $_post['installment1']; $due_date1 = $_post['due_date1']; $ins_amt2 = $_post['installment2']; $due_date2 = $_post['due_date2']; $ins_amt3 = $_post['installment3']; $due_date3 = $_post['due_date3']; $ins_amt4 = $_post['installment4']; $due_date4 = $_post['due_date4']; $ins_amt5 = $_post['installment5']; $due_date5 = $_post['due_date5']; $ins_amt6 = $_post['installment6']; $due_date6 = $_post['due_date6']; $ins_amt7 = $_post['installment7']; $due_date7 = $_post['due_date7']; $ins_amt8 = $_post['installment8']; $due_date8 = $_post['due_date8']; $ins_amt9 = $_post['installment9']; $due_date9 = $_post['due_date9']; $ins_amt10 = $_post['installment10']; $due_date10 = $_post['due_date10']; $ins_amt11 = $_post['installment11']; $due_date11 = $_post['due_date11']; $ins_amt12 = $_post['installment12']; $due_date12 = $_post['due_date12']; $ins_amt13 = $_post['installment13']; $due_date13 = $_post['due_date13']; $ins_amt14 = $_post['installment14']; $due_date14 = $_post['due_date14']; $ins_amt15 = $_post['installment15']; $due_date15 = $_post['due_date15']; $ins_amt16 = $_post['installment16']; $due_date16 = $_post['due_date16']; $ins_amt17 = $_post['installment17']; $due_date17 = $_post['due_date17']; $ins_amt18 = $_post['installment18']; $due_date18 = $_post['due_date18']; $ins_amt19 = $_post['installment19']; $due_date19 = $_post['due_date19']; $ins_amt20 = $_post['installment20']; $due_date20 = $_post['due_date20']; $ins_amt21 = $_post['installment21']; $due_date21 = $_post['due_date21']; $ins_amt22 = $_post['installment22']; $due_date22 = $_post['due_date22']; $ins_amt23 = $_post['installment23']; $due_date23 = $_post['due_date23']; $ins_amt24 = $_post['installment24']; $due_date24 = $_post['due_date24']; $items = array(); $installment[] =array($ins_amt1, $ins_amt2, $ins_amt3, $ins_amt4, $ins_amt5, $ins_amt6, $ins_amt7, $ins_amt8, $ins_amt9, $ins_amt10, $ins_amt11, $ins_amt12, $ins_amt13, $ins_amt14, $ins_amt15, $ins_amt16, $ins_amt17, $ins_amt18, $ins_amt19, $ins_amt20, $ins_amt21, $ins_amt22, $ins_amt23, $ins_amt24);  //$in_values= serialize($installment);   $due_date[] = array($due_date1, $due_date2, $due_date3, $due_date4, $due_date5, $due_date6, $due_date7, $due_date8, $due_date9, $due_date10, $due_date11, $due_date12, $due_date13, $due_date14, $due_date15, $due_date16, $due_date17, $due_date18, $due_date19, $due_date20, $due_date21, $due_date22, $due_date23, $due_date24); //$in_dates= serialize($due_date); //$s1 = "insert installment(id, fee_id, student_id, amount, due_date, paid_date, status, rec_no) values ('', ".$fee_id.", '".$roll_no."', ".$in_values.", '".$in_dates."', '', 'unpaid', ''";  foreach($installment $row_key => $value) {     $item  = $value;     $uom = $due_date[$row_key];  $items[] = sprintf("(%d, %d, '%s', %d, '%s', '%s', '%s', '%s')", '',                                                                            $fee_id,                                                                            mysql_real_escape_string($roll_no),                                                                              intval($item),                                                                            $uom,                                                                            '',                                                                            '',                                                                             ''                                                                            ); }   $msql = 'insert installment (id, fee_id, student_id, amount, due_date, paid_date, status, rec_no) values '.implode(', ', $items); 

but taking 1 data. can please suggest. data has saved this:

like http://netelity.com/saveddata.jpg

a normal insert statement should like:

insert table_name (column1,column2,column3,...) values (value1,value2,value3,...); 

so try changing

$msql = 'insert installment (id, fee_id, student_id, amount, due_date, paid_date, status, rec_no) values '.implode(', ', $items); 

to:

$values = implode(', ', $items); $msql = 'insert installment (id, fee_id, student_id, amount, due_date, paid_date, status, rec_no) values ('.$values.'); 

and don't forget run sql command. don't see in script anywhere :)


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -