Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to store data from loop textbox in mysql database?
09-12-2015, 06:08 PM
Post: #1
How to store data from loop textbox in mysql database?
I want to enter scores for each courses retrieved from the database and store all the courses back in the database
Below is my code:

PHP Code:
<b>Registered Courses:</b>
          <
table width="535" border="0">
        <
tr>
          <
th width="74" scope="col">Code</th>
          <
th width="356" scope="col">Course Title</th>
          <
th width="62" scope="col"Unit</th>
          <
th width="70" scope="col">Score</th>
        </
tr><form action='coursesform.php' method='POST'>
        <?
php
        $query 
mysql_query("SELECT * FROM c_reg WHERE uid = '$id2' ORDER BY id ASC");
        
$total mysql_num_rows($query);
        while(
$info mysql_fetch_array($query)){
        
$id $info['id'];
        
$code=$info['code'];
        
$name=$info['name'];
        
$unit=$info['unit'];
        if(isset(
$_POST['submit'])){
            
$score $_POST['score'];
            foreach (
$_POST['submit'] as $key
    {    
    
$score $_POST['score'][$key];
            
$queryy "INSERT INTO gp(uid,code,name,unit,score,semester) VALUES('$id2','$code','$name','$unit','$key','First')";
            
$queryy mysql_query($queryy);
    }
}
?>
        <tr>
       
       </div>
       <?php
       
echo "<td><input type='hidden' name='$code'><p align='center'>$code</p></td>
    <td><input type='hidden' name='
$name'><p align='center'>$name</p></td>
    <td><input type='hidden' name='
$unit'><p align='center'>$unit</p></td>
    <td><p align='center'><input type='text' size='4' name='score[]' value='
$score' ></p></td>
  </tr>"
;
 
  
      }
      
  
?>
      </table>
      <br clear="all" />
      <input type="submit" name="submit" value="Submit" align="middle" />
      </form> 
Find all posts by this user
Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)