【问题标题】:Php help to remove remove td linephp帮助删除删除td行
【发布时间】:2016-06-10 01:32:24
【问题描述】:

你好,我刚刚创建了我的支持系统,我得到了带有 echo 的ticket detalis,但它显示所有 td 行作为图片我只需要显示第一行

我的代码

<table cellpadding="0" cellspacing="0" border="0" class="data">
<thead>
<tr>
    <th width="115"><p2>Ticket ID</p2></th> 
    <th width="90"><p2>Status</p2></th>
    <th width="160"><p2>Ticket Topic</p2></th>
    <th width="160"><p2>Client</p2></th>
</tr>
</thead> 
<tr>    <?php
           echo "<td><a href='?page=ticket&id=".$row[id]."'</a>#".$row[id]."</td>";
           echo "<td>".$row[status]."</td>";
           echo "<td>".$row[naslov]."</td>";
            $userr = mysql_query('SELECT * FROM client WHERE clientid='.$row["user_id"].'');
            $useri = mysql_fetch_array($userr);     
           echo "<td><a href='clientsummary.php?id=".$row[user_id]."'</a>".$useri['firstname']." ".$useri['lastname']."</td>";
        ?>
</tr>       

【问题讨论】:

  • 那么它需要相当多或重写请不要使用the mysql_ database extension,它已被弃用(在PHP7中永远消失了)特别是如果你只是学习PHP,花你的学习PDO 数据库扩展的能量。 Start here 真的很简单
  • 不要“自己动手” 嗯? @RiggsFolly 我自己通常喜欢知道“里面”是什么,什么是“被吸收”。 ;-) 编辑:啊,您进行了编辑并且在上下文中失去了所有意义。
  • 整个代码块是否被包裹在一个循环中?将表格标题移到循环之外。
  • 是的,包含在其他 php 文件中
  • 在我看来,这个输出取决于一个查询,而我们看不到循环这真是个乐于助人的人

标签: php echo html-table


【解决方案1】:

您需要将表格标题移到循环之外。没有看到循环的机制,我猜它需要看起来像这样:

<table cellpadding="0" cellspacing="0" border="0" class="data">
<thead>
<tr>
    <th width="115"><p2>Ticket ID</p2></th> 
    <th width="90"><p2>Status</p2></th>
    <th width="160"><p2>Ticket Topic</p2></th>
    <th width="160"><p2>Client</p2></th>
</tr>
</thead> 
<tbody>

<?php include 'missing.query.on.other.script.php'; 

while ($row = mysql_fetch_array($whatever_resource)){

?>



<tr>    <?php
           echo "<td><a href='?page=ticket&id=".$row[id]."'</a>#".$row[id]."</td>";
           echo "<td>".$row[status]."</td>";
           echo "<td>".$row[naslov]."</td>";
            $userr = mysql_query('SELECT * FROM client WHERE clientid='.$row["user_id"].'');
            $useri = mysql_fetch_array($userr);     
           echo "<td><a href='clientsummary.php?id=".$row[user_id]."'</a>".$useri['firstname']." ".$useri['lastname']."</td>";
        ?>
</tr>

<?php } // end while ?>

</tbody>
</table>

【讨论】:

    猜你喜欢
    • 2015-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-09
    • 1970-01-01
    相关资源
    最近更新 更多