PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
im supposed to edit a form and in that form there is a radio button as well. im not sure how to retrive the value of the radio button from database. kindly help. the code is given below: i couldnt get the value of the radio button. the database table structure is also given below:
<?php
include('header.inc');
$_SESSION['iddd']=$_GET['id1'];
if(isset($_GET['id1'])) {
require_once('mysql_connect.php');
$query="SELECT * from objective WHERE hw_id={$_GET['id1']}";
$result=@mysql_query($query);
$row=mysql_fetch_array($result);
}
if(isset($_POST['submit']))
{ require_once('mysql_connect.php');
$i=$_POST['iii'];
$abc=$_POST['orig'];
$mno=$_POST['kl'];
$sql="UPDATE objective SET orig='$abc',ach='$def',nach='$ghi',
indi='$jkl',kl='$mno' WHERE hw_id='$i'";
$result=@mysql_query($sql);
if($result) { echo 'Your Report is updated, ';
echo "Click Next to continue with editing";
$url1="edits3.php?id1=$i "; ?>
<button onClick="window.location='<?php echo $url1;?>'">Next>></button>
<?php include ('footer.inc');
exit();}
}
?>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<fieldset><legend><font size="4" color="blue">OBJECTIVE ACHIEVEMENT
</font</legend>
<input type="hidden" name="iii" VALUE="<?php echo $row['hw_id'] ?>"/>
<table width="100%" bgcolor="#d0d8ea">
<tr><td><font face="Arial" size="3"><b>1. Original Project Achievement</b><br><font face="Times" size="3" color="blue"><i>(State the specific project objectives as described in proposal)</i><br>
<p><textarea name="orig" rows="4" cols="70" align="center">
<?php echo $row['orig']; ?>
</textarea></p>
<hr></td></tr>
<tr><td><font face="Arial" size="3"><b>5. How would you characterize the quality of this output ? </b><br><br>
<? echo $mno; ?>
<input name="kl" type="radio" value="sig"<? echo $mno; ?><?=($mno=='sig') ? ' checked' : '' ?> />Significant breakthrough <br>
<input name="kl" type="radio" value="maj"<? echo $mno; ?><?=($mno=='maj') ? ' checked' : '' ?> />Major improvement <br>
<input name="kl" type="radio" value="min"<?=($mno=='min') ? ' checked' : '' ?> />Minor improvement <br><HR>
</td></tr>
</table>
<div align="center"><input type="submit" name="submit" value="UPDATE REPORT"/> </div>
</form>
database structue:
CREATE TABLE `objective` (
`hw_id` int(11) NOT NULL default '0',
`orig` text NOT NULL,
`ach` text NOT NULL,
`nach` text NOT NULL,
`indi` text NOT NULL,
`kl` char(3) NOT NULL default '0'
) TYPE=MyISAM;
$mno probably does not have the value you expected. An essential debugging method would also to have viewed the source and see if the word "checked" is being outputted into the HTML code, if it is then you know your problem is with your HTML syntax, if it is not then you need to debug your PHP code (which is what the above will do)..
Let's say for instance the value of $mno is not what you expected, you then look in your script to wherever you assigned $mno it's value and you play around with that code trying to "isolate" the error, try this for instance, instead of doing whatever you are doing now to assign $mno it's value explicitly set it to what you expect it's value to be:
Well the problem then is, you are not sending POST data to the script..
What is supposed to be posting this data?
When you put $mno = 'min' did the var_dump still read out NULL? (if it did ignore my above statements about the POST data). Try to play with this on your own as much as you can, logically debugging and isolating the issue, it's going to really pay off in the long run as a PHP developer to learn the debugging process like this