这段代码正在为我需要它做的事情而工作,但是(在我看来)它看起来很糟糕,所以我希望有人知道一种更清洁或更有效的方法来做同样的事情。我从数据库中提取了几个条目,我希望它们的样式相同。只有徽标和链接名称最终会更改,我将添加说明。这是代码:
<div class="content">
<?PHP
while($row = $stmt->fetch())
{
$name = $row['name'];
$id = $row['id'];
$logo = $row['logo'];
$username = $row['username'];
echo "<div class=" . "Links" . ">";
echo "<div class=" . "linkImages" . ">";
echo "<br>" . "<a href=" . "Profile.php?id=".$id . ">" . "<img src=" . "users/" . $username . "/images/" . $logo . " " . "width=" . "200" . " " . "height=" . "auto" . " " . "border=" . "0" . "/>" . "</a>";
echo "</div>";
echo "<div class=" . "linkName" . ">";
echo "<a href=" ."Profile.php?id=".$id .">" . $name ."</a>";
echo "</div>";
echo "</div>";
}
?>
</div>