如何在while循环中使用href?

时间:2018-01-02 23:52:16

标签: php html sql

我正在尝试回复帖子表中发布的每个帖子的链接。我正在检查时,$stmt = $pdo->query('SELECT id, userid, postTitle, postDate, postUrl, votes FROM posts ORDER BY votes DESC'); while ($row = $stmt->fetch()) { ?> <a href="<?php $row['postUrl'] ?>">Link</a> <?php } 标签内是否有正确的信息,但我无法点击它?对于这里发生的一些信息非常有用,我该如何解决?这就是我想要做的事情:

目前,我将链接文字作为链接无法点击

Sub arraytest()

Dim myArray As Variant
Dim i As Integer

myArray = ActiveWorkbook.Worksheets("Semesters").ListObjects("tblSemester").DataBodyRange.Value

For i = 1 To UBound(myArray, 1)
    myArray(i, 5) = "18/19"
    myArray(i, 6) = "Fall"
Next

Worksheets("Sheet1").Range("A2").Resize(UBound(myArray, 1), UBound(myArray, 2)).Value = myArray

End Sub

1 个答案:

答案 0 :(得分:3)

您忘记结束PHP标记或添加echo,您必须在while循环开始时结束PHP标记,并在标记之后添加另一个PHP标记。或者你可以添加如下的回声!祝你好运!

尝试这个!

<?php
$stmt = $pdo->query('SELECT id, userid, postTitle, postDate, postUrl, votes FROM posts ORDER BY votes DESC');
while ($row = $stmt->fetch()) {
?>
    <a href="<?php echo $row['postUrl']; ?>">Link</a>
<?php
}
?>