Jump to content

radio buttons


rainemaida

Recommended Posts

Ok, I am trying to change the value in table with radio buttons. If one radio button is selected it changes the value in the field to 'y' and if the other is selected it changes the field to 'n'.

 

So first of all I need to bring back the values from the table and have the correct radio box selected, then I need to be able to update it. also both cannot be selected at the same time (which I why i think i'm supposed to use radio buttons).

 

currently...

 

<input type="text" name="umobile" value="'.$value[7].'" />

 

That brings back the letter 'y' which for me means yes. and of course 'n' means no.

 

Please can you help me out.

 

Cheers,

Steve

Link to comment
https://forums.phpfreaks.com/topic/45316-radio-buttons/
Share on other sites

<?

// Get the ID of the chosen thing and store it in a variable
$id = $_GET['id'];

// If the submit button is pressed, execute the update code
if (isset($_POST['Submit']))
{
// Store the new values inserted into the form in variables
$u_email=$_POST['uemail'];
$u_mobile=$_POST['umobile'];
$u_sEmail=$_POST['usubscribedEmail'];
$u_sMobile=$_POST['usubscribedMobile'];

// Store the update query string in a variable
     $update="UPDATE user SET email='$u_email', mobile='$u_mobile', subscribedEmail='$u_sEmail', subscribedMobile='$u_sMobile' WHERE userID='$id'";

// Execute the query on the database
$updated = mysql_query($update);

if($updated)
{
	// Output a confirmation message telling the user that the update was successful
	echo 'Record Updated';
}
else
{
	// Output error message if the update was not executed successfully
	echo 'Error, Update not successful';
}

}

// Store the query string to select the chosen things details from the table
$query="SELECT * FROM user WHERE userID='$id'";

// Execute the query on the database
$result = mysql_query($query);

echo "<p class='leftmargin'><font face='arial'><a href='coursedocumentsstudent.php'>Course Documents ></a> Preferences</p>";
echo "<img src='images/seperator.jpg' width='100%' height='20'>";

// Store the results in an array and print them in a clear format
while ($value = mysql_fetch_array($result))
{
// Display the form with the returned data in it
	echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" >';
echo '<table width="90%" align="center">';
echo '<tr><td><b>E-Mail Settings</b><br></td></tr>';
echo '<tr><td><font color="black" size="2px" face="arial">E-Mail Address:</td><td> <input type="text" name="uemail" value="'.$value[4].'" /></td></tr></table>';
echo '<br><img src="images/seperator.jpg" width="100%" height="20"><br>';
echo '<table width="90%" align="center">';
echo '<tr><td><b>Mobile Phone Settings</b><br></td></tr>';
echo '<tr><td><font color="black" size="2px" face="arial">Mobile Number:</td><td> <input type="text" name="umobile" value="'.$value[5].'" /></td></tr><br></table>';
echo '<p align="right"><input type="Submit" value="Update" name="Submit" /></form>';

}


 

$u_sEmail=$_POST['usubscribedEmail'];

 

 

I need radio buttons for these the above. so 'y' means you are subscribed to email and 'n' means u aren't.

 

Cheers,

Steve

Link to comment
https://forums.phpfreaks.com/topic/45316-radio-buttons/#findComment-220058
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.