我有以下PHP, 我的问题是;如何使href根据值生成自己 $行['类别'] 如果有任何不清楚的地方,请告诉我。
<?php
echo "<div class=News>";
$q = "SELECT * FROM post ORDER BY newsno DESC";
$r = mysqli_query($mysqli, "$q");
if($r)
{
while($row=mysqli_fetch_array($r)){
echo "<form action=index.php method=post>";
echo "<div class=Container>";
echo "<div class=Newsheader>";
echo "<h7>";
echo $row['newstopic'];
echo "</h7>";
echo "</div>";
echo "<a href=image.php?newsno=".$row['newsno']." data-lightbox=roadtrip><img src=image.php?newsno=".$row['newsno']." width=180 height=180/></a>";
echo "<div class=tb>";
echo nl2br(substr ($row['newsinfo'], 0, 50));
echo "<a href='This/Is/My/problem"."'> ...Read more</a>";
echo "</div>";
echo "</div>";
echo "<div class=newsfooter>";
echo 'Category: ' . $row['category'];
echo "</div>";
echo "</br>";
echo "</br>";
echo "</form>";
}
echo "</div>";
}
else
{
echo mysqli_error();
}
?>
答案 0 :(得分:1)
如果您尝试根据类别制作动态网址,而不是放置
echo '<a href="https://www.vg.no/'.$row['category'].'"> ...Read more</a>';