As i can see you have taken fm and pm but you need to have array type here find below code to get it understood
<?php
include_once('dbconfig.php');
$mysql="Select * from subjects where class_id='$class_id' ";
$result=mysql_query($mysql); ?>
<form method='post' action='insert.php'>
<?php
while($row=mysql_fetch_array($result)) {
echo $row['subject_name'];
?>
<input type='text' name='fm[]' placeholder='fullmarks' class='input-small'>
<input type='text' name='pm[]' placeholder='passmarks' class='input-small'>
<br/>
<?php } ?>
<button id='classbutton' name='submit' class='btn btn-success'> Save</button>
</form>
and insert.php you can use Like this
for($i = 0; $i <count($_POST)-1; $i++)
{
mysql_query("INSERT INTO `marks`(`fm`,`pm`) VALUES('".$_POST['fm'][$i]."','".$_POST['pm'][$i]."');");
}
Here marks as a table name and fm,pm are table colume