Hi,

I have 2 radio buttons which needs to submit a checked value to the database and then retrieve the same when called back in to display...any idea where i can get an example for this..

thanks a lot..

can you post the form code so I can make the php code based on that.

can you post the form code so I can make the php code based on that.

<?php
include 'init.php';

if (!is_authed())
{
        header("Location: http://xxxxxxxx/login.php?fail=3");
        exit;
}
$ID = $_SESSION['ID'];

$results = mysql_query("SELECT * FROM `WorkExperience` WHERE ID=$ID");
$row = mysql_num_rows($results);
if($row == 0)
{
        mysql_query("INSERT INTO `WorkExperience` (ID) VALUES ('$ID')");
}

if($_POST['save'] || $_POST['next'])
{



$WorkExperienceYesNo = $_POST['WorkExperienceYesNo'];



$query = "UPDATE `WorkExperience` SET WorkExperienceYesNo='$WorkExperienceYesNo'' WHERE ID=$ID";
mysql_query($query);
}

if($_POST['next'])
{
        header("Location: http://xxxxxxx/pg7.php");
        exit();
}

$query = "SELECT * FROM `WorkExperience` WHERE ID=$ID";
$results = mysql_query($query);
$data = mysql_fetch_array($results);

$WorkExperienceYesNo = $data['WorkExperienceYesNo'];


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<TITLE>Graduate Admission System (Research Programme)</TITLE>

<link href="CSS/GraduateProgram.css" rel="stylesheet" type="text/css">

</head>

<body bgcolor="#FFFFFF" topmargin="0">

<table width=1000 align="center" border="0" cellspacing="0" cellpadding="0" bgcolor="#FF6600">
    <tr>
      <td bgcolor="#FFFFFF"><img src="images/xxxx.png" alt="xxxxxxx" width="450" height="92"></td>
    </tr>
</table>
 
  <br>
<table width=1000 border="0" align="center" cellpadding="3" cellspacing="0" bgcolor=white style="border:1px solid #999999;" valign=top>
  <TR>
    <td height="30" colspan=3 align="left" valign="middle" bgcolor=#ff9933 class="BodyTextHeaders" >Section VII - Employment History</td>
  </TR>
  <TR>
    <td colspan=3 align="left" valign="top" bgcolor=white class="BodyText" > Application Number :</td>
  </TR>
  <TR>
    <td colspan=3 align="left" valign="top" bgcolor=white class="BodyText" > Applicant Name :</td>
  </TR>
  <TR>
    <td colspan=3 align="left" valign="top" bgcolor=white class="BodyText" > Please note that only personal details can be amended.
      For amendments on other data, please contact the 
    administrator for assistance. </td>
  </TR>
  <TR>
    <td colspan=3 align="left" valign="top" bgcolor=white class="BodyText" > Items indicated with an asterisk * are mandatory. </td>
  </TR>
  <TR>
    <td colspan=3 align="left" valign="top" bgcolor=white class="BodyText" >Items indicated with a + are necessary for that section</td>
  </TR>
</TABLE>
  <br>


<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post" name="pg6.php"> 
  <TABLE  border=0 ALIGN="center" cellpadding = 3 cellspacing = 0  width="1000" style="border:1px solid #999999;">



<TR>
<td width="136%" height="30" align="left" bgcolor=#ff9933 class="BodyTextHeaders">
			
			(A) Work Experience (Last 5 Years)	</td>
</TR>



<TR>
<td valign="topleft" bgcolor=#E8E8E8 class="BodyText" >
			
			Have you had any work experience relating to your proposed area of research?

              <input type="radio" name="WorkExperienceYesNo" value="Yes" "<?=$WorkExperienceYesNo?>"  >
              Yes
              <input type="radio" name="WorkExperienceYesNo" value="No" "<?=$WorkExperienceYesNo?>"  checked>
              No    </td>
</TR>
</TABLE>
  <br />

<div id="div"></div>

  <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <th scope="col"><input type="button" class="BodyText"  onclick="generateRow()" value="Add More Work Experience's" /></th>
    </tr>
  </table>
  <BR>
  
  <TABLE  border=0 ALIGN="center" cellpadding = 3 cellspacing = 0 width="1000" style="border:1px solid #999999;">
    <TR>
      <td height="30" align="left" valign="middle" bgcolor=#ff9933 class="BodyTextHeaders">Important Notes</td>
    </TR>
    <TR>
      <td height="100" align="left" valign="middle" bgcolor=white><ul>
          <li class="BodyText">If you have entered information in the above
          section, please click the "Save Changes" button. </li>
        <li class="BodyText"> If no information is updated, please click "Next Section" button. </li>
        <li class="BodyText">Clicking the "Main Menu" button will bring
        you back to the screen listing all sections.</li>
        <li><span class="BodyText">Please click the "Log Out" button to exit.</span><br>
        </li>
      </ul></td>
    </TR>
  </TABLE>
  
  <div align="center">
    <p><br>
      <input name="next" type="submit" class="BodyText" id="Proceed" value="Proceed to Next Section">
      <input name="save" type="submit" class="BodyText"  value="Save Changes">
      <input name="reset" type="reset" class="BodyText" id="reset" value="Clear Form">
      <input name="logout" type="submit" class="BodyText"  value="Logout">
  </div>

</form>

  

</p>
    <p align="center">7/12<br>
    </p>


</BODY>
</HTML>
<input type="radio" name="WorkExperienceYesNo" value="Yes" >Yes
         <input type="radio" name="WorkExperienceYesNo" value="No">
              No

when the user clicks either yes or no will get insert....use ordinarry insert query

<input type="radio" name="WorkExperienceYesNo" value="Yes" >Yes
         <input type="radio" name="WorkExperienceYesNo" value="No">
              No

when the user clicks either yes or no will get insert....use ordinarry insert query

Hi,

Thanks for you reply..but my need is a bit more complicated than this...i do know how to do this.....

here is what my above code does....

it accepts the input from the form once the user is logged in and authenticated....the values are stored and then retrieved as and when the user needs it....the radio button field has the same name ....i am using the value attrib to insert the user input as you can see from the code...my sql table has only one field set to receive the data from the radio button....below the specific code..

if($_POST['save'] || $_POST['next'])
{ 

$WorkExperienceYesNo = $_POST['WorkExperienceYesNo'];
<input type="radio" name="WorkExperienceYesNo" value="Yes" "<?=$WorkExperienceYesNo?>" >
              Yes
              <input type="radio" name="WorkExperienceYesNo" value="No" "<?=$WorkExperienceYesNo?>" checked>
              No    </td>

R u trying something like this .............

<?php

$WorkExperienceYesNo="yes";


 if($WorkExperienceYesNo == "yes")
{ ?>
<input type="radio" name="WorkExperienceYesNo" value="Yes" <? echo "CHECKED"; ?>>
              Yes
<input type="radio" name="WorkExperienceYesNo" value="No" > No    </td>
<? }      
    
else
{ ?>
<input type="radio" name="WorkExperienceYesNo" value="Yes">
              Yes
           <input type="radio" name="WorkExperienceYesNo" value="No"  <? echo "CHECKED"; ?>> No    </td>
<? } ?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.