I prefer to do it in php not in mysqli because of time.
How to insert part of column in MySQL using php ?
For example ,my column table in sql are : courseid, code, title, cr ,prerequisite, std_id, status, grade . I used table to fetch the data in php , but status and grade are empty of data because I want user to inter them to see what courses each student complete from the list of courses . I want user to insert them with the other column that are fixed with specific data . The problem i face in this code is that the insert data is coming in new record and i want to insert in just two column which are status and and Grade with the names of course .
How to insert in just in Status and Grade
enter code here
<?php
error_reporting(0);
include('config.php');
$sql="select * from studyplan";
$result=mysql_query($sql);
while ($row = mysql_fetch_array($result)){
$id=$row['courseid'];
$code=$row['code'];
$Title=$row['title'];
$cr=$row['cr'];
$pre=$row['prerequisite'];
$std=$row['std_id'];
$status=$row['status'];
$grade=$row['grade'];
echo "<tr class='edit_tr' id='$id'>
<td class='edit_td'>
<span class='text' id='one_$id' >$id </span>
</td>
<td class='edit_td'>
<span class='text' id='one_$id' >$code </span>
</td>
<td class='edit_td'>
<span class='text' id='two_$id' >$Title</span>
</td>
<td class='edit_td'>
<span class='text' id='three_$id' >$cr</span>
</td>
<td class='edit_td'>
<span class='text' id='three_$id' >$pre</span>
</td>
<td class='edit_td'>
<span class='text' id='three_$id' >$std</span>
</td>
<td class='edit_td'>
<span class='text' id='three_$id' >$status</span>
<select name='status' id='status'>
<option value=''>Completed</option>
<option value='B'>Not complate</option>
</select>
</td>
<td class='edit_td'>
<span class='text' id='three_$id' >$grade</span>
<select name='grade' id='grade'>
<option value=''>A</option>
<option value='B'>B</option>
<option value='C'>C</option>
<option value='D'>D</option>
<option value='F'>F</option>
</select>
</td>
</tr>";
}
echo '<input type="hidden" name="courseid" value="' . $id . '" />';
?>
<p align="center"><a href="year.html">Go Back</a> </p>
<p><input type="submit" value="Add Link"></p>
</tr>
</table>
</form>
</div>
</body>
</html>
<?php
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$status=$_POST['status'];
$grade=$_POST['grade'];
Insert statement
$SQL = " INSERT INTO studyplan ";
$SQL = $SQL . " (status, grade) VALUES ";
$SQL = $SQL . " ('$status', '$grade') ";
$result = mysql_db_query($db,"$SQL",$cid);
if (!$result) {
echo("ERROR: " . mysql_error() . "\n$SQL\n"); }
echo ("New Link Added\n");
}
mysql_close($cid);
?>
i want it like small pic