dongyongju9560 2013-10-01 08:42
浏览 51
已采纳

单选按钮php mysql

I have a problem with the radio button, I can edit and insert but it does not show me anything. what I'm doing wrong? Thank you in advance for your help enter image description here

radio button

<input type="radio" name="visible" value="0"<?php 
                if ($id['visible'] == 0) { echo " checked"; } 
                ?> /> {no}
                &nbsp;
                <input type="radio" name="visible" value="1"<?php 
                if ($id['visible'] == 1) { echo " checked"; } 
                ?> /> {yes}

id

enter if(isset($_POST['id'])){
$id=$_POST['id'];
}else{
$id=$_GET['id'];
//echo $id;
} here



@$query  = "SELECT * FROM photographs WHERE id = '$id' ";
    //pokazuje co zostalo zmienione
    echo $query;

    $result = mysqli_query($connection, $query);
    if (!$result) {
        die("zapytanie sie nie powiodlo");
    }
    $row = mysqli_fetch_array($result);

?>
  • 写回答

1条回答 默认 最新

  • dsbpaqt61965 2013-10-01 08:48
    关注

    Your array is $row so $id['visible'] should be changed to $row['visible'].

    <input type="radio" name="visible" value="0"<?php 
                    if ($row['visible'] == 0) { echo " checked"; } 
                    ?> /> {no}
                    &nbsp;
    <input type="radio" name="visible" value="1"<?php 
                    if ($row['visible'] == 1) { echo " checked"; } 
                    ?> /> {yes}
    

    Side note: your code is vulnerable to SQL Injection. Consider switching to a Prepared Statement.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后的密码
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面