1

我在 php 中有一个 html 表

<?php
        $result = mysqli_query($con,"SELECT * FROM recepten ORDER BY datum DESC");



        echo "<table border='1'  class='ms-list8-main'>
        <tr>
        <th class='ms-list8-top'>Link</th>
        <th class='ms-list8-top'>Naam</th>
        <th class='ms-list8-top'>Beschrijving</th>
        <th class='ms-list8-top'>Datum</th>

        </tr>";

        while($row = mysqli_fetch_array($result))
          {
          echo "<tr>";
          echo "<td><a href='$url'>link</td>";
          echo "<td class='ms-list8-even'>" . $row['naam'] . "</td>";
          echo "<td class='ms-list8-even'>" . $row['beschrijving'] . "</td>";
          echo "<td class='ms-list8-even'>" . $row['datum'] . "</td>";
          echo "</tr>";
          }
        echo "</table>";
        $url = $row['url'];         
        ?>

链接echo "<td><a href='$url'>link</td>";失效

链接的名称在一个名为“url”的 sql 表中

链接在每一行都不同

我怎样才能让它工作?

4

2 回答 2

2

那是因为$url从未定义过。PHP 应该给你一个错误并抱怨它。你的警告出现了吗?

你的意思是$row['url']

例如:

while($row = mysqli_fetch_array($result))
{
     echo "<tr>";
     // I've manually concatenated for clarity.
     echo "<td><a href='". $row['url'] ."'>link</td>";
     echo "<td class='ms-list8-even'>" . $row['naam'] . "</td>";
     echo "<td class='ms-list8-even'>" . $row['beschrijving'] . "</td>";
     echo "<td class='ms-list8-even'>" . $row['datum'] . "</td>";
     echo "</tr>";
}
于 2013-10-15T20:20:41.887 回答
0

它应该是...

$row['url']

不是

$url
于 2013-10-15T20:21:51.770 回答