hi i am making content management system
so when i edit some subject or i want to update subject if the subject update sucessfully it display msg subject update sucessfully i dnt know give any name to then it shud display error subject not updated
i have written code but it not working like supppose i want to change the name of subject previous it was hello if i remove hello and click on update button it should display error cant not update
in my script when i do this it just rremove the name its run update statement
this is my code kindly help me out
it doesnt shows errors msgs
my code is
$query= "UPDATE subjects SET menu_name= '{$menu_name}', position ={$position}, visible ={$visible} WHERE id = {$id}";
$result=mysql_query($query,$connection);
if(mysql_affected_rows()==1){
// sucess
$message = " The subject was sucessfully updated";
}else { //failed
$message = " The subject updated failed";
$message .="<br/>".mysql_error();
}
}else {//error occur
$message = "there were".count($errors)." errors in the form.";
}
}//end of the if (isset(_spost)
find_selected_page();
include("includes/header.php");
?>
<table width="100%" id="Structure">
<tr>
<td width="19%" bgcolor="#660000" id="nevigation">
<?php navigation($sel_subject,$sel_page);?>
</td>
<td width="81%" bgcolor="#CCCCCC"id="pages">
<h2> Edit Subject:<?php echo $sel_subject['menu_name'];?></h2>
<?php if(!empty($message))
{
echo "<p class=\">" .$message ."</p>";
} ?>
<form action="edit_subject.php?subj=<?php echo urlencode($sel_subject['id']);?>" method="post">
<p> Subject name:<input type="text" name="menu_name" value="<?php echo $sel_subject['menu_name'];?>" id="menu_name" /></p>
<p> position: <select name="position">
<?php $subject_set= get_all_subjects();
$subject_count= mysql_num_rows($subject_set);
for ($count=1;$count<= $subject_count+1;$count++){
echo"<option value=\"{$count}\"";
if($sel_subject['position']==$count){
echo "selected";}
echo ">{$count}</option>";
}?>
</select>
</p>
<p> visible : <input type="radio" name="visible" value="0"<?php if($sel_subject['visible']==0){echo "checked";}?> />No
<input type="radio" name="visible" value="1" <?php if($sel_subject['visible']==1){echo "checked";}?> />YES
</p>
<input type="submit" name="submit" value="Edit Subject" />
</form>
<br/>
<a href="content.php">Cancel</a>
</td>
</tr>
</table>
<?php require("includes/footer.php");?>