I have problem the data is not updating in the database .
I got this message :
0 rows have been updated with: update studyplan set complated = '', passed = '' where courseid = '41'
<body>
<form action="up.php" name="frmAdd" method="post">
<div align='center'>
<table border='1' cellpadding='5' cellspacing='1' id='mytable'>
<tr align='center'>
<th>courseid</th>
<th>code</th>
<th>Title</th>
<th>Cr</th>
<th>prerequisite</th>
<th>STDid</th>
<th>complated</th>
<th>passed</th>
</tr>
<?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'];
$complated=$row['complated'];
$passed=$row['passed'];
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' ></span>
<select name='complated' id='complated'>
<option value=''>Yes</option>
<option value=''>No</option>
</select>
</td>
<td class='edit_td'>
<span class='text' id='three_$id' ></span>
<select name='passed' id='passed'>
<option value=''>Yes</option>
<option value=''>No</option>
</select>
</td>
</tr>";
}
echo '<input type="hidden" name="courseid" value="' . $id . '" />';
?>
<p align="center"><a href="year.html">Go Back</a> </p>
<input type="submit" name="submit" value="save" class="button">
</tr>
</table>
</form>
</div>
</body>
</html>
PHP update for complete and passed selection option when user click yes or no.
<?php
$usr = "fsdf";
$pwd = "dfg";
$db = "data6";
$host = "localhost";
$cid = mysql_connect($host,$usr,$pwd);
if (!$cid) {
echo("ERROR: " . mysql_error() . "\n");
}
?>
<?php
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$id=$_POST['courseid'];
$complated=$_POST['complated'];
$passed=$_POST['passed'];
$SQL= "update studyplan ";
$SQL.= " set complated = '".$complated."', ";
$SQL .= " passed = '".$passed."' ";
$SQL .= "where courseid = '".$id."' ";
$result = mysql_db_query($db,"$SQL",$cid);
if($result) {
echo mysql_affected_rows() . " rows have been updated with: $SQL";
} else {
echo "data has not been updated";
}
}
?>
\n"; Then run it and copy the string printed to the screen and try it in phpMyAdmin to see what happens. – Trevor Dec 23 '15 at 06:53