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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?