insert multiple table rows via a php into mysql -


i inserting multiple line values html table form in sql it's inserting last table form value in database. can't figure out problem is.

can me out this?

this php:

$result = mysql_query("select * ex_marks session='$session' , cl_name='$cl_name' , cl_section='$cl_section' , subject='$subj' , exam='$exam' , date='$date' , roll_no='$rollno' , obtainmarks='$marks'");  if (mysql_num_rows($result) == 0) {     mysql_query("insert ex_marks(mid, session, cl_name, cl_section, name, fname, status, date, exam, roll_no, subject, obtainmarks, maxmarks, passmarks)     values('', '$session', '$cl_name', '$cl_section', '$name','$fname', '$attendance', '$date', '$exam', '$rollno', '$subj','$marks','$maxmarks','$passmarks')") or die(mysql_error());      echo "<script type='text/javascript'>alert('submitted successfully!')</script>"; }  else {      echo "<script type='text/javascript'>alert('already exist!')</script>"; } 

}

and form values inserted:

<div id="page-wrapper">         <div class="container-fluid">             <div class="row">                 <div class="col-lg-12">                     <h1 class="page-header">assign marks</h1>                     <div class="col-lg-6">                         <div class="panel">                                 <form method="post">                             <!--<div class="form-group">                                 <input type="text" size="15" name="date" id="name[]"  class="tcal form-control"  placeholder="exam date" required="required"/>                             </div>-->                             <div class="form-group">                                 <input class="form-control" type="text" size="17" name="maxmarks" placeholder="total marks" required="required"/>                             </div>                             <div class="form-group">                                 <input class="form-control" type="text" size="17" name="passmarks" placeholder="pass marks" required="required"/>                             </div>                                 <button name="btn_sub" type="submit" class="btn btn-info">submit</button>                          </div>                     </div>                     <!-- /.col-lg-12 -->                 </div>             </div>             <!-- /.row -->             <div class="row">             <div class="col-lg-12">                 <div class="panel panel-default">                     <div class="panel-heading">          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;session :         <?php             $session=$_get['session'];             echo $session;?>          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class :         <?php             $cl_name=$_get['cl_name'];             echo $cl_name;?>          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;section :         <?php             $cl_section=$_get['cl_section'];             echo $cl_section;?>          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;subject :         <?php              $subj = $_get['subj'];             echo $subj;?>          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exam date :         <?php              $date=$_get['date'];                 echo $date;?>          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exam :         <?php              $exam=$_get['exam'];             echo $exam;?>                     </div>                     <!-- /.panel-heading -->                     <div class="panel-body">                         <div class="datatable_wrapper">                             <table class="table table-striped table-bordered table-hover" id="datatables-example">                                 <thead>                                     <tr>                                         <th>no.</th>                                         <th class="text-center">name</th>                                         <th class="text-center">roll no</th>                                         <th class="text-center">father name</th>                                         <th class="text-center">scored marks</th>                                         <th class="text-center">attendance</th>                                     </tr>                                 </thead>                                 <tbody>                         <?php                             $key="";                             if(isset($_post['searchtxt']))                                 $key=$_post['searchtxt'];                             if($key !="")                                 $sql_sel1=mysql_query("select * ex_attendance session '%$key%' , cl_name '%$key%' , cl_section '%$key%'");                             else                                 $sql_sel1=mysql_query("select * ex_attendance session='$session' , cl_name='$cl_name' , cl_section='$cl_section' , exam='$exam' , date='$date' , subject='$subj'");                             $i=0;                             while($row1=mysql_fetch_array($sql_sel1))                             {                                 $i++;                                 $color=($i%2==0)?"lightblue":"white";                         ?>                                     <tr class="odd gradex">                                         <td><?php echo $i;?></td>                                         <td align="center"><input size="17" type="text" name="name" value="<?php echo $row1['f_name']." ".$row1['m_name']." ".$row1['l_name'];?>" readonly="readonly"/></td>                                         <td align="center"><input size="13" type="text" name="rollno" value="<?php echo $row1['roll_no']?>" readonly="readonly"/></td>                                         <td align="center"><input size="17" type="text" name="fname" value="<?php echo $row1['fname']?>" readonly="readonly"/></td>                                         <td align="center"><input size="17" type="text" name="marks" required="required"/></td>                                         <td align="center"><input size="17" type="text" name="attendance" id="name[]" value="<?php echo $row1['status'];?>" readonly="readonly"/></td>                                     </tr>                         <?php   }?>                                 </form>                                 </tbody>                             </table>                         </div>                     </div>                     <!-- /.table-responsive -->                 </div>                 <!-- /.panel-body -->             </div>             <!-- /.panel -->             </div>             <!-- /.col-lg-12 -->         </div>     </div> 


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -