douhuan1497
2015-12-14 09:13
浏览 12
已采纳

如何使用PHP显示和合并PostgreSQL中的表?

I am trying to display data from data base. I want to make it grouped. Here is the template enter image description here

I made the code like this :

<?php
    $queg=pg_query("SELECT agentgroup.leadername,agentgroup.reviewername, agentgroup.supervisorname, agent.onlinename from agentgroup left join agent on agentgroup.agentid=agent.agentid order by agentgroup.leadername");

    echo "<td class=\"form1\" align=\"center\" > Number </td>";
    echo "<td class=\"form1\" align=\"center\" > Agent Group </td>";
    echo "<td class=\"form1\" align=\"center\" > Coach </td>";
    echo "<td class=\"form1\" align=\"center\" > Supervisor </td>";
    echo "<td class=\"form1\" align=\"center\" > Agent Online Name </td>";
    echo "<td class=\"form1\" align=\"center\" ></td>";
   $gcount=1;
    while($grow=pg_fetch_array($queg)){
            echo "<tr>";
            echo "<td class=\"forma\" rowspan=\"8\" align=\"center\"> ".$gcount++."</td>";
            echo "<td class=\"forma\" rowspan=\"8\" align=\"left\"style=\"padding-left:10%;\"> ".$grow['leadername']." </td>";
            echo "<td class=\"forma\" rowspan=\"8\" align=\"left\"style=\"padding-left:10%;\"> ".$grow['reviewername']." </td>";
            echo "<td class=\"forma\" rowspan=\"8\" align=\"left\"style=\"padding-left:10%;\"> ".$grow['supervisorname']." </td>";
            echo "<td class=\"forma\" align=\"left\"style=\"padding-left:10%;\"> ".$grow['onlinename']." </td>";
            echo "<td class=\"forma\" rowspan=\"4"align=\"center\"><a href=\"#\" >edit</a></td>
                    </tr>";}
?>

But I got chaos.this is the current output enter image description here

Any help to display those data? Thank you :D

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • dongyi1111 2015-12-17 10:21
    最佳回答

    The database design was wrong I guess. In case its already happen, than u shouldnt display the data like that. try to pass the specified data to new page via url ( href ) and then display them one by one by specify the coach or agent group

    <?php
        $queg=pg_query("SELECT distinct  leadername, reviewername, supervisorname from agentgroup order by leadername");
    
        echo "<td class=\"form1\" align=\"center\" > Number </td>";
        echo "<td class=\"form1\" align=\"center\" > Agent Group </td>";
        echo "<td class=\"form1\" align=\"center\" > Coach </td>";
        echo "<td class=\"form1\" align=\"center\" > Supervisor </td>";
        echo "<td class=\"form1\" align=\"center\" ></td>";
        echo "<td class=\"form1\" align=\"center\" ></td>";
    
        $gcount=1;
        while($grow=pg_fetch_array($queg))
        {
                echo "<tr>";
                echo "<td class=\"forma\"  align=\"center\"> ".$gcount++."</td>";
                echo "<td class=\"forma\"  align=\"left\"style=\"padding-left:10%;\"> ".$grow['leadername']." </td>";
                echo "<td class=\"forma\"  align=\"left\"style=\"padding-left:10%;\"> ".$grow['reviewername']." </td>";
                echo "<td class=\"forma\"  align=\"left\"style=\"padding-left:10%;\"> ".$grow['supervisorname']." </td>";
                echo "<td class=\"form2\" align=\"center\"><a href=viewpergorup.php?viewnamegroup=".urlencode($grow['leadername'])."><img src=\"image\\view.png\" width=\"20px\" height=\"20px\" style=\"padding-left:22%;cursor:pointer;\"></td>";
    
            }
    

    make the page : view_agentgroup. There the details is displayed

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题