php - All columns not inserted in the database -
whenever try insert more 1 row in database table 1 row gets inserted. have tried methods , still cannot insert rows @ once. html code
<?php error_reporting(0); include ('includes/workprogress_func.php'); ?> <body> </ul> </div> <div id="rightcol"> <div id="content" align="center"> <h1 align="center">workplan progress form</h1> <div id="table1" class="container" align="left"> <form name="form1" action="" method="post"> <table width="398" height="118" border="0" align="left" > <td> <tr> <td > <p>division name:</p> </td> <td> <input name="divisionname" type="text" value="" /></td> </tr> <tr> <td><p>division chief: </p></td> <td> <input type="text" name="divisionchief" /></td> </tr> <tr> <td><p> period: </p> </td> <td> <input type="text" name="period" /></td> </tr> <tr> <td><p> month:</p> </td> <td> <input type="month" name="month" > </td> </tr> </table> </div> <div id="table2"> <table border="1" align="center" cellpadding="1" cellspacing="1" > <tr> <td rowspan="2" align="center"> sn </td> <td rowspan="2" align="center"> activity name </td> <td rowspan="2" align="center" > unit </td> <td rowspan="2" align="center"> weightage </td> <td colspan="4" align="center"> performance indicators(percentage)</td> <td colspan="3" align="center"> performance achievement </td> <td colspan="2" align="center"> indicator measurement basis </td> <tr> <td align="center">100 </td> <td align="center"> 75</td> <td align="center"> 50 </td> <td align="center"> <50 </td> <td align="center">measurement </td> <td align="center"> score</td> <td align="center"> progress </td> </tr> <tr> <td width:60px > 1</td> <td> <input type="text" name="activityname[]" style="width:100px"/> </td> <td> <input type="text" name="unit[]" style="width:50px" /> </td> <td> <input type="text" name="weightage[]" style="width:80px"/> </td> <td> <input type="text" name="per100[]" style="width:50px"/> </td> <td> <input type="text" name="per75[]" style="width:50px" /> </td> <td> <input type="text" name="per50[]" style="width:50px"/> </td> <td> <input type="text" name="perless50[]" style="width:50px"/> </td> <td> <input type="text" name="measurement[]" style="width:100px"/> </td> <td> <input type="text" name="score[]" style="width:50px"/> </td> <td> <input type="text" name="progress[]" style="width:80px"/> </td> <td> <input type="text" name="indicatormeasure[]" style="width:150px"/> </td> </tr> <tr> <td width:60px > 2</td> <td> <input type="text" name="activityname[]" style="width:100px"/> </td> <td> <input type="text" name="unit[]" style="width:50px" /> </td> <td> <input type="text" name="weightage[]" style="width:80px"/> </td> <td> <input type="text" name="per100[]" style="width:50px"/> </td> <td> <input type="text" name="per75[]" style="width:50px" /> </td> <td> <input type="text" name="per50[]" style="width:50px"/> </td> <td> <input type="text" name="perless50[]" style="width:50px"/> </td> <td> <input type="text" name="measurement[]" style="width:100px"/> </td> <td> <input type="text" name="score[]" style="width:50px"/> </td> <td> <input type="text" name="progress[]" style="width:80px"/> </td> <td> <input type="text" name="indicatormeasure[]" style="width:150px"/> </td> </tr> <tr> <td width:60px > 3</td> <td> <input type="text" name="activityname[]" style="width:100px"/> </td> <td> <input type="text" name="unit[]" style="width:50px" /> </td> <td> <input type="text" name="weightage[]" style="width:80px"/> </td> <td> <input type="text" name="per100[]" style="width:50px"/> </td> <td> <input type="text" name="per75[]" style="width:50px" /> </td> <td> <input type="text" name="per50[]" style="width:50px"/> </td> <td> <input type="text" name="perless50[]" style="width:50px"/> </td> <td> <input type="text" name="measurement[]" style="width:100px"/> </td> <td> <input type="text" name="score[]" style="width:50px"/> </td> <td> <input type="text" name="progress[]" style="width:80px"/> </td> <td> <input type="text" name="indicatormeasure[]" style="width:150px"/> </td> </tr> <tr> <td width:60px > 3</td> <td> <input type="text" name="activityname[]" style="width:100px"/> </td> <td> <input type="text" name="unit[]" style="width:50px" /> </td> <td> <input type="text" name="weightage[]" style="width:80px"/> </td> <td> <input type="text" name="per100[]" style="width:50px"/> </td> <td> <input type="text" name="per75[]" style="width:50px" /> </td> <td> <input type="text" name="per50[]" style="width:50px"/> </td> <td> <input type="text" name="perless50[]" style="width:50px"/> </td> <td> <input type="text" name="measurement[]" style="width:100px"/> </td> <td> <input type="text" name="score[]" style="width:50px"/> </td> <td> <input type="text" name="progress[]" style="width:80px"/> </td> <td> <input type="text" name="indicatormeasure[]" style="width:150px"/> </td> </tr> </table> </br> </div> <div align="center"> <input name="submit" type="submit" value="submit" /> <label> <input name="h" type="hidden" id="h" value="0" /> </label> </form> </div> </div> </div> </body> </html>
and php code insertion
<?php if (isset($_post['submit'])) { include('includes/connect.php'); $num = $_post['h']; ($i=0; $i<=$num; $i++) { $divisionname=$_post['divisionname']; $divisionchief=$_post['divisionchief']; $period=$_post['period']; $month=$_post['month']; $activityname=$_post['activityname'][$i]; $unit=$_post['unit'][$i]; $weightage=$_post['weightage'][$i]; $per100=$_post['per100'][$i]; $per75=$_post['per75'][$i]; $per50=$_post['per50'][$i]; $perless50=$_post['perless50'][$i]; $measurement=$_post['measurement'][$i]; $score=$_post['score'][$i]; $progress=$_post['progress'][$i]; $indicatormeasure=$_post['indicatormeasure'][$i]; $sql="insert `workplan_progress` (`name`, `chief`, `timeperiod`, `workmonth`, `activity_names`, `workunit`, `workweightage`, `percent_100`, `percent_75`, `percent_50`, `percent_less50`, `measure`, `score`, `progress`, `indicator_measure`) values ('$divisionname', '$divisionchief', '$period', '$month', '$activityname', '$unit', '$weightage', '$per100', '$per75', '$per50', '$perless50', '$measurement', '$score', '$progress', '$indicatormeasure')"; mysql_query($sql); //echo "$sql"; //header("location:workplan.php"); } echo"this information has been added database."; } ?>
can please me out!!!
<input name="h" type="hidden" id="h" value="0" /> $num = $_post['h']; ($i=0; $i<=$num; $i++)
value = 0 , 0<=0 1 loop ;-)
you set in html h 0, $num allways 0. can set $num count of submited rows by
$num = count($_post['activityname']);
but works if fill out activityname field or can set $num count of rows.
Comments
Post a Comment