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

单选按钮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);

?>

图片转代码服务由CSDN问答提供 功能建议

我的单选按钮有问题,我可以编辑和插入,但它没有显示任何内容。 我做错了什么? 提前感谢您的帮助

单选按钮

 &lt; input type =“radio”name =“visible”value =“0”&lt;?php 
 if($ id ['visible'] =  = 0){echo“checked”;  } 
?&gt;  /&GT;  {no} 
&amp; nbsp; 
&lt; input type =“radio”name =“visible”value =“1”&lt;?php 
 if($ id ['visible'] == 1){echo  “检查”;  } 
?&gt;  /&GT;  {是} 
   
 
 

id

 输入if(isset($ _ POST ['id'])){  
 $ id = $ _ POST ['id']; 
} else {
 $ id = $ _ GET ['id']; 
 // echo $ id; 
}这里
 
 
 
 
 
 
  n @ $ query =“SELECT * FROM pictures WHERE id ='$ id'”; 
 // pokazuje co zostalo zmienione 
 echo $ query; 
 
 $ result = mysqli_query($ connection,$ query); \  n if(!$ result){
 die(“zapytanie sie nie powiodlo”); 
} 
 $ row = mysqli_fetch_array($ result); 
 
?&gt; 
   
 
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

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.

    点赞 打赏 评论

相关推荐 更多相似问题