简体   繁体   中英

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. 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 
$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>";
    }
}


The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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