mamradzelvy
mamradzelvy

Reputation: 17

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>";
          }
    }
?>

Upvotes: 1

Views: 673

Answers (1)

Hello World
Hello World

Reputation: 2907

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


Upvotes: 2

Related Questions