尝试使用PHP中的删除按钮从表中删除行 [英] Try to delete row from table using delete button in PHP

查看:203
本文介绍了尝试使用PHP中的删除按钮从表中删除行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<pre><?php
include 'conn.php';

$result = ("SELECT * FROM usrdata"); // selecting data through mysql_query()
$count=mysqli_query($conn,$result);

echo'<table border=1px>';  // opening table tag
echo'<th>id</th><th>email</th><th>Password</th>'; //table headers

while($data = mysqli_fetch_array($count))
{
// we are running a while loop to print all the rows in a table
echo'<tr>'; // printing table row
echo '<td>'.$data['id'].'</td><td>'.$data['email'].'</td><td>'.$data['password'].'</td>'; // we are looping all data to be printed till last row in the table
echo '<td><input type="button" name="delete" value="delete"></td>';

}

echo'</tr>'; // closing table row
echo '</table>';

if($_GET){
    if(isset($_GET['delete'])){
        delete();
    }//elseif(isset($_GET['select'])){
        //select();
    //}
}

    function delete()
    {
    	$delete1 =("DELETE FROM `usrdata` WHERE id = '$id'");
        $result = mysqli_query($conn,$delete1) or die(mysqli_error());
        
	echo "record deleted";
   
   
 
    }

?>




我尝试过的事情:

我尝试使用按钮单击将整个行删除到表中.但是按钮已响起事件没有响应




What I have tried:

i am try to delete entire row into table using button click. but button is clikced event is dosen''t responsed

推荐答案

结果 =(" SELECT * FROM usrdata"); // 通过mysql_query()选择数据


count = mysqli_query (
count=mysqli_query(


conn,


这篇关于尝试使用PHP中的删除按钮从表中删除行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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