Jump to content

Changing Radio Button option to variable


mikebyrne

Recommended Posts

I want it to when the user selects "Show" the word YES will pass to the Display field in my databasae and f the user selects "Hide" the words NO will pass to the dispaly fields

 

At present my PHP looks like

 

<?PHP

require_once("adminconnect.php");

$ProductNo = mysql_real_escape_string(trim($_POST['ProductNo']));
$ProductName = mysql_real_escape_string(trim($_POST['ProductName']));
$Description = mysql_real_escape_string(trim($_POST['Description']));
$Price = mysql_real_escape_string(trim($_POST['Price']));
$Stockamount = mysql_real_escape_string(trim($_POST['Stockamount']));
$Type = $_POST['Type'];

$tbl_name="product";

$sql="INSERT INTO $tbl_name (Producttype, ProductNo, ProductName, Description,Price) VALUES ('$Type','$ProductNo', '$ProductName', '$Description', '$Price')";
mysql_query($sql);

echo $_POST['ProductNo'];
echo $_POST['ProductName'];
echo $_POST['Description'];
echo $_POST['Price'];
echo $_POST['Stockamount'];
echo $_POST['Type'];
echo $sql;

?>

 

 

<div class="editRightText">Display:</div>
              <div class="editRightForm">
                <div class="editRadio1">
                  <input name="display" type="radio" value="yes" checked="checked" />
                </div>
                <div class="editRadio2">show</div>
                <div class="editRadio3">
                  <input name="display" type="radio" value="no" />

Link to comment
Share on other sites

Is it enough ?

..
$Disp = mysql_real_escape_string(trim($_POST['display']));
..
..
$sql="INSERT INTO $tbl_name (Producttype, ProductNo, ProductName, Description,Price,Display) VALUES ('$Type','$ProductNo', '$ProductName', '$Description', '$Price', '$Disp')";
..
..
echo $_POST['display'];

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.