I have two radio button that are value 0 and 1 stored in mysql database after that i want to enable(when value is =1) or disable(when value is =0) button. i new to php please give me code for that some thing like that...
<input type="submit" ... <?php&nbs
p;if (/* condition not met */)
echo "disabled='disabled'" ?>">

Edited by Web_2: code

3 Years
Discussion Span
Last Post by Web_2

Try This

  <label > Radio</label>
    <input type="radio" name="r1" id="0" value="0"   <?php if(isset($rws['radio1']) && $rws['radio1'] =="0"){ ?> disable <?php }?>>
    <input type="radio" name="r1" id="1" value="1"  <?php if(isset($rws['radio2']) && $rws['radio2'] == "1"){?>  <?php }?>>
    Radio2 </div>

Hi Ketul,
Thanks for reply but actualy i want this in diff. ways my program is like that
Page 1-
in that i have Two RADIO button that value is 0 and 1 stored in mysql database.
Page 2-
in that i have BUTTON to corresponding to Page 1 RADIO button, i want to enable/disable BUTTON corresponding to RADION button value (i.e. 1 or 0 stored in database) plz give me help.


ya can u send me ur email id so i will send u images


If you're posting the value of the radio to a different page, you might be over-complicating it by over-thinking it.

Page 2:

    // Posted value from Page 1
    $radio_value = $_POST['radio_element'];

    if($radio_value == 0) {
        <button type="button" disabled>You can't click me!</button>
    } else {
        <button type="button">Click away!</button>

Using what the guys have said about obtaining the $radio variable:

Solution to your version

<input name="xyz" <?php if($radio == 0){echo "disabled='disabled'";} ?> />

Neater version


$input = "<input name='xyz'";

if($radio == 0)
    $input .= " disabled='disabled'";

$input .= " />";

echo $input;


Edited by mattster


Hi mattster,
Thanks Very much Its Working ur code Thanks again see u again.
i want know where r u from ?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.