简体   繁体   English

如何通过 php 在 html 表中回显超链接

[英]how to echo a hyperlink in a html table via php

I'm trying to put together a table that would have one show a hyperlink based on the ID in the database.我正在尝试整理一个表格,该表格将根据数据库中的 ID 显示一个超链接。 I can not figure out the proper arrangement to get it working.我无法弄清楚让它工作的正确安排。 What am I doing wrong?我究竟做错了什么?

<?php 
    $sqlactive= "SELECT * from Tabule1 WHERE TabStatus LIKE '0'";
    $result = $conn->query($sqlactive);
    if ($result->num_rows > 0) {
        while ($row = $result-> fetch_assoc()) {
            echo "<tr>
            <td>" . $row["TabKlient"] . "</td>
            <td>" . $row["TabOsoba"] . "</td>
            <td>" . $row["TabItem"] . "</td>
            <td>" . $row["TabQty"] . "</td>
            <td>" . $row["TabNote"] . "</td>
            <td>" . $row["TabAddedBy"] . "</td>
            <td>" . $row["TabDate"] . "</td>"
            '<td><a href="edit.php?id='.$row['ID'].'"> test </a></td>' "</tr>";
          }
    }
?>

your code syntax doesn't seem ok.您的代码语法似乎不对。

Please have a look at your syntax and try请查看您的语法并尝试

Here is the corrected php code I fixed for you这是我为您修复的更正的 php 代码

<?php 
$sqlactive= "SELECT * from Tabule1 WHERE TabStatus LIKE '0'";
$result = $conn->query($sqlactive);
if ($result->num_rows > 0) {
    while ($row = $result-> fetch_assoc()) {
        echo "<tr>
            <td>" . $row["TabKlient"] . "</td>
            <td>" . $row["TabOsoba"] . "</td>
            <td>" . $row["TabItem"] . "</td>
            <td>" . $row["TabQty"] . "</td>
            <td>" . $row["TabNote"] . "</td>
            <td>" . $row["TabAddedBy"] . "</td>
            <td>" . $row["TabDate"] . "</td>" . // <--- notice the dot here
            '<td><a href="edit.php?id='.$row['ID'].'"> test </a></td>' . /* <-- another dot here */ "</tr>";
    }
}


声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM