douchun6221 2015-12-02 07:13
浏览 51
已采纳

从循环显示的视图列表中删除数据库行

I have a view list that displayed through php

$quedchan=pg_query("SELECT agent.agentname,  agent.onlinename, agent.channel, agentgroup.leadername FROM Agent LEFT JOIN agentgroup on agent.agentid=agentgroup.agentid where agent.channel like '%$DCH%'order by agent.channel");
    echo "<td class=\"form1\" align=\"center\" > Number </td>";
    echo "<td class=\"form1\" align=\"center\" > Agent Name </td>";
    echo "<td class=\"form1\" align=\"center\"> Agent Online Name </td>";
    echo "<td class=\"form1\" align=\"center\"> Agent Channel </td>";
    echo "<td class=\"form1\" align=\"center\"> Agent Group </td>";
    echo "<td class=\"form1\" align=\"center\">  </td>";

$counttttt=1;
    While($row3=pg_fetch_array($quedchan))
echo "<tr>";
        echo "<td class=\"forma\" align=\"center\"> ".$counttttt++." </td>";
        echo "<td class=\"forma\"name=\"dement\" align=\"left\"style=\"padding-left:10%;\"> ".$row3['agentname']." </td>";
        echo "<td class=\"forma\" align=\"left\"style=\"padding-left:8%;\"> ".$row3['onlinename']." </td>";
        echo "<td class=\"forma\" align=\"left\"style=\"padding-left:8%;\"> ".$row3['channel']." </td>";
        echo "<td class=\"forma\"align=\"left\"style=\"padding-left:6%;\"> ".$row3['leadername']." </td>";
        echo "<td class=\"forma\" align=\"center\"><img src=\"image\\delete.png\" width=\"20px\" height=\"20px\" style=\"padding-left:22%;cursor:pointer;\"/></td>
        </tr>";     

And I want to make a delete function, so that the delete image of a row can delete its row. I made this by give a name for agentname row, name=\"dement\". in order to catch the value I want to delete. Im using php in another page called delete.php :

<?php 
session_start();
include 'connect.php';

$dagname=$_GET['dement'];
$queda="DELETE FROM Agent where agentname='$dagname'";
$result=pg_query($queda);


if($result)
{   
    $_SESSION['delMessage11']='Selected Agent is successfully deleted!';
    header('Location: Dagent.php');
}
else
{
    echo "ERROR!"; 
}

?>

It doesnt work. I tried to use a reference from http://www.phpeasystep.com/mysql/7.html. it says I can get value of id (which I replace with agentname now) that sent from address bar. I implement it and become this

echo "<td class=\"form2\" align=\"center\"><a href=\"delete.php?agentname=<?    echo ".$row3['agentname'].";?>\">\"<img src=\"image\\delete.png\" onclick=\"dela();\" width=\"20px\" height=\"20px\" style=\"padding-left:22%;cursor:pointer;\"/></a></td>
                    </tr>";

But it doesnt work. Any help? Thank you

  • 写回答

1条回答 默认 最新

  • duandang2123 2015-12-18 02:37
    关注

    Why don't you use method ="get"? it's more simple. So when the button was clicked, 'something' (based on you need) would be save in a variable and directly move on into a new page which is filled by delete queries and use $_GET for catch the variable(filled by 'something') for support the queries and the attributes. when you are moving on into a new page then you will see the link, it would be like this

    DATA_NAME.php?$something.
    

    I Hope this can help you. :)

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

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料