我有一个页面,我将数据从 mysql 调用到表中。我正在尝试创建一种情况,他们可以单击表格上的日期,然后将他们链接到另一个页面。这是我正在处理的代码
$q = "SELECT*FROM forum";
$r = mysqli_query($dbc,$q);
if (mysqli_num_rows($r)>0)
{
echo'<table><tr><th>Posted By</th>
<th>Subject</th><th id="msg">Message</th></tr>';
while ($row=mysqli_fetch_array($r,MYSQLI_ASSOC))
{
echo'<tr>
<td>'.$row['first_name'].''.$row['last_name'].'<br>
'.$row['post_date'].'</td>
<td>'.$row['subject'].'</td><td>'.$row['message'].'</td>
</tr>';
}
echo '</table>';
}
else
{echo '<p>There are currently no messages.</p>';}
我正在尝试在此代码上放置 anchor 标记
'.$row['post_date'].'
我试过了
<a href="edit.php">'.$row['post_date'].'</a>
但是没有成功
最佳答案
试试这个:
<a href="edit.php"><?php echo $row['post_date']; ?></a>
或更短的变体:
<a href="edit.php"><?= $row['post_date']; ?></a>
关于php - 如何在 anchor 标记中调用php变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41811938/