PHP:如何获取单选按钮的值,然后在SQL statemet中使用它

时间:2019-01-04 01:26:23

标签: javascript php html

如何获取单选按钮的值并将其用于我的SQL语句。我创建了一个脚本,但是不起作用:(

预期结果:

我希望下拉菜单取决于单选按钮的值

脚本:

<tr>
    <td><br><input type="radio" name="lockin"   value="1" checked /> Yes </td> 
    <td><br><input type="radio" name="lockin"   value="0"/>No    </td> 
</tr>

    <tr>
        <td   ><br>Reason for Disconnection</td>
            <td><br>
                <select id="reasondd"  name="R" onChange="change_reason()"  width="40" >

                <option id="mySelect" value="" selected="selected" >Select</option> 
                <?php 

                if(isset($_POST['lockin'])) {
                    if($_POST['value'] == 1) {
                $WhereC= 1;
                }   elseif($_POST['value'] == 0) {
                $WhereC=0;
                }}
                $res=mysqli_query($link,"SELECT DISTINCT discon_reason FROM note_gen2 where lock_in_stat = '$WhereC' order by discon_reason asc");  
                while ($row=mysqli_fetch_array($res)) {

                ?>
                <option value="<?php echo $row['discon_reason'];?>"><?php echo $row["discon_reason"]; ?></option>
            <?php } ?>
            </select>
        </td>
    </tr>

1 个答案:

答案 0 :(得分:-1)

在此没有$ WhereC。

$ res = mysqli_query($ link,“从note_gen2选择DISTINCT discon_reason,其中lock_in_stat ='$ WhereC'由discon_reason asc命令”);