-1

Here i am creating the system for e

<?php  

    include("inc/config.php");
    include("inc/functions.php"); 
    
    
    if(isset($_REQUEST['submit'])){
 
 
    $acadimic_exam_id = $_REQUEST['id'];
    $subject_id = $_REQUEST['subject_id'];
    $exam_date = $_REQUEST['exam_date'];
    $exam_duration = $_REQUEST['exam_duration'];
    $total_marks = $_REQUEST['total_marks'];
    $passing_marks = $_REQUEST['passing_marks'];
    $upload_exam_paper = $_REQUEST['upload_exam_paper'];
    
    
    
    $string = "insert into  exam_deatils SET
    acadimic_exam_id = '".$acadimic_exam_id."',
    subject_id = '".$subject_id."',
    exam_date = '".$exam_date."',
    exam_duration = '".$exam_duration."',
    total_marks = '".$total_marks."',
    passing_marks = '".$passing_marks."', 
    upload_exam_paper = '".$upload_exam_paper."'"; 
    
    query($string);
    $msg="New Exam has been added successfully";
    header("location:make_exam.php?mess=$msg"); 
     
  
  }
 
 
 
   
?>
<!doctype html>
<html class="no-js" lang="en">
<!--<![endif]-->
 <?php  
 
 include("inc/head.php"); 
  
 ?>

<body>





 <?php  include("inc/lock-slider.php");  ?>
  
 <?php include("inc/script-main.php");  ?>
 
 <?php include("inc/toolbar.php"); ?>
 
 <?php include("inc/header.php"); ?>
 
 <?php  include("inc/admininstrator.php"); ?>
 
 <?php  include("inc/left-menu.php"); ?>
 
 
 <section id="content" class="container_12 clearfix" data-sort=true>
   <h1 class="grid_12">All Current Exams</h1> 
   <div class="grid_12">
    <div class="box">
     <div class="header">
      
      <h2>Dynamic Table (Current Exam) </h2> 
      
     </div>
     <div class="content"> 
     
     <form action="" method="POST">
      <table class="dynamic styled" data-filter-Bar="always" data-table-tools='{"display":false}'>
      
       <thead>
        <tr>
          
         <th>Sr No</th>
         <th>Subjects</th>
         <th>Exam Date</th>
         <th>Duration (HR)</th>
         <th>Total Marks</th>
         <th>Passing Marks</th>
         <th>Upload Exam Paper</th>
         
         
        </tr>
       </thead>
       <tbody>
       
        <?php
        
      
        $getting_subjects = "Select * from tbl_subjects where class_id='".$_REQUEST['class_id']."'";
        $sub_result = query($getting_subjects);
        $sr_no = 1;
        while($sub_res = mysqli_fetch_array($sub_result))
        
        
        {
        
        ?>
         <tr> 
         <td><?php echo $sr_no;  ?></td>
         <td><?php echo $sub_res['subject_name'];  ?></td>
         <td><input type="date" name="exam_date" id="exam_date"/></td>
         <td>
         <select name="exam_duration" id="exam_duration">
           <option value="0:30">0:30</option>
           <option value="0:45">0:45</option>
           <option value="0:60">0:60</option>
           <option value="1:00">1:00</option>
           <option value="1:30">1:30</option>
           <option value="1:45">1:45</option>
           <option value="2:00">2:00</option>
           <option value="2:30">2:30</option>
           <option value="2:45">2:45</option>
           <option value="3:00">3:00</option>
           <option value="3:30">3:30</option>
           <option value="3:45">3:45</option>
           <option value="4:00">4:00</option>
         </select>
         
         </td>
         <td><input type="text" name="total_marks" id="total_marks"/></td>
         <td><input type="text" name="passing_marks" id="passing_marks"/></td>
         <td><input type="file" name="upload_exam_paper" id="upload_exam_paper"/></td>
        </tr>
        
        <tr>
         <td></td>
         <td></td>
         <td></td>
         <td></td>
         <td></td>
         <td></td>
          
          <?php
          
          $sr_no++;
          
          }
          
          ?>        
         <td>
         
 <input type="submit" name="submit" id="submit" value="Submit" >
 <a href=""><input type="submit" name"" id="" value="Cancel"></a>
 
         </td>
         
        </tr>
         
         
       </tbody>
       
        
      </table>
      </form>
     </div>
    </div>
   </div>
   
  
  </section>
 </div>
 
 <?php  include("inc/footer.php");?>
 
 
  
 
 
 <script>
  $$.loaded();
 </script>
 <!--[if lt IE 7 ]><script defer src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script> <script defer>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script><![endif]-->
</body>
 
</html>

xamination using PHP, i had created two tables one is getting fundamental exam detail and other is getting other exam details relevant to that exam id. i looped input fields per the class subjects in that exam. and i am getting perfect record as per all subjects relevant to that exam but only one record is going in the top one other subjects with their fields are not getting records . .. . . . i am using simple php with mysqli every body please assist me for the sake of you lovable programming languages . . .. i am stuck in it from last 5 days enter image description here

enter image description here

Rp9
  • 1,955
  • 2
  • 23
  • 31
  • Your code is vulnerable to SQL injection. You should use prepared statements. See https://stackoverflow.com/q/7537377/1839439 – Dharman Dec 18 '19 at 07:06

1 Answers1

0

Once you submit the form there is only one insert on the server side. You must also note that after submit the page will stop running and no other submits will happen. Sounds like you want to aggregate the data on client side and move the loop into you submit handling

in need of help
  • 1,606
  • 14
  • 27