如何通过使用PHP中的单选按钮从数据库中删除数据? [英] How to delete data from database by using radio button in php?

查看:226
本文介绍了如何通过使用PHP中的单选按钮从数据库中删除数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上,这是主要问题.它没有获得可在此处用作条件的"$ radio [$ i]"语句的值.所以有人会告诉我我要在这里写些什么,而不是"$ radio [$ i]",因为输出会出现.

Actually here is the main problem. It does not get the value of "$radio[$i]" statement that can be used as a condition here. So will anyone please tell me what I have to write there instead of "$radio[$i]" as the output will come.

<?php
if(isset($_POST['delete']))
{
    for($i=0;$i<$count;$i++)
    {
        $del_id = $radio[$i];
        $sql = "DELETE FROM reigster WHERE id='".mysql_real_escape_string($del_id)."'";
        $result = mysql_query($sql);
    }
    if($result)
    {
        echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">";
    }
}
mysql_close();
?>

推荐答案

尝试一下

if(isset($_POST['delete']))
{
    for($i=0;$i<$count;$i++)
    {
        $del_id = $radio['checked'];
        $sql = "DELETE FROM reigster WHERE id='".mysql_real_escape_string($del_id)."'";
        $result = mysql_query($sql);
    }
    if($result)
    {
        echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.

这篇关于如何通过使用PHP中的单选按钮从数据库中删除数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆