Hi Friends,
Firstly, I apologize for the lengthy post.
I am a beginner in PHP programming and I am using WAMP server for my php development.
I would really appreciate it if anyone of you all can help me with a problem I have with posting a radio button selection. Here is what I am doing..
I have a form which selects and displays all the users from the database whose Status="RJ". I should be able to change the status of the user, in the form, to "PD" or "RG" using a radio button selection. Once I select a radio button option and hit submit, the user should disappear from the current page(as his status got changed) and I should be able to see him in a different page.
So, weirdly the problem is, this form works sometimes and sometimes it doesn't, though I dont make any changes to the code. When I make a selection and hit submit, nothing happens. I tried to print the new status of the user after I hit submit, but nothing is returned. So what I understood is, the radio button selection is sometimes returning me an empty string rather than the selected value.
I tried a stupid fix to this problem by changing the status everywhere to "R" instead of "RJ" and again changed it back to "RJ"-it started working!! I repeat it again and now it doesn't work. I know its an illogical temporary fix. Waiting for a logical solution from someone.
Please find my code below.
Thanks !!
<?php
$qry = "SELECT * FROM registration WHERE Status='RJ'";
$sqlmembers=mysql_query($qry);
$num_rows=mysql_num_rows($sqlmembers);
for($i=1;$i<=$num_rows;$i++)
{
$info=mysql_fetch_assoc($sqlmembers);
?>
<tr>
<td> <?php echo $info['Facility']; ?> </td>
.
.
.
<?php $facility=$info['Facility'];
?>
<td>
<input type="radio" name="<?php echo $facility; ?>" value="PD"/>PD
<input type="radio" name="<?php echo $facility; ?>" value="RG"/>RG
</td>
.
.
if(isset($_POST['submit']))
{
//update db
$qry1 = "SELECT * FROM registration WHERE Status='RJ'";
$members=mysql_query($qry1);
$num_rows=mysql_num_rows($members);
for($i=1;$i<=$num_rows;$i++)
{
$info=mysql_fetch_assoc($members);
$fac= $info['Facility'];
$new_status=$_POST[$fac];
.
.
if($new_status!='') {
echo $new_status;
mysql_query("UPDATE registration SET Status='$new_status' WHERE Facility='$fac'") or die(mysql_error());
print "<p style=\"color : #C11B17;\">The changes are successfully updated!</p>";
}
