Why is PHP not allowing comparison?

Posted by dcp3450 on Stack Overflow See other posts from Stack Overflow or by dcp3450
Published on 2010-03-23T15:02:52Z Indexed on 2010/03/23 15:13 UTC
Read the original article Hit count: 495

Filed under:
|
|

I'm using PHP to read if an entry in my table on the database is set to "yes" or "no" and auto check the radio button that corresponds:

<?php include 'file.php';
$query = "SELECT * FROM TABLE";
$runquery = odbc_exec($connect,$query);
$status= odbc_result($runquery,"status");
odbc_close($file);
?>
<form>
<div class="formContainer">
    <fieldset>
    <legend>Campus Alert<span class="tooltip">Turn campus alert on and off.</span></legend>
        <?php echo $status; ?>
        Yes <input type="radio" name="alertStatus" id="alertStatus" value="yes" <?php if($status== "yes") echo "checked";?>>
        No <input type="radio" name="alertStatus" id="alertStatus" value="no" <?php if($status== "no") echo "checked";?>>
    </fieldset>
</div>

the is for debugging so I can make sure what the database says and the form's reaction is correct. It prints "yes" (no quotes). However, the if statement will not respond. Any idea why it's doing this?

© Stack Overflow or respective owner

Related posts about php

Related posts about if-statement