我正在上一些在线课程,在其中一个练习中,我们要为博客创建两个表 - 博客文章和博客文章 - 并通过外键连接它们,然后显示两者的所有内容.评论应仅与特定文章相关联,同时还允许多条评论.
我的尝试:
function list_articles() {
include('core/db/db_connection.php');
$sql = "SELECT blog.title, blog.content, blog.posted_by, blog.date, article_comments.comments, article_comments.comment_by
FROM blog LEFT OUTER JOIN article_comments
ON blog.content_id = article_comments.content_id
WHERE blog.content != ''
ORDER BY blog.content_id DESC";
$result = mysqli_query($dbCon, $sql);
while ($row = mysqli_fetch_array($result)) {
echo
"<h5 class='posted_by'>Posted by " . $posted_by = $row['posted_by'] . " on " . $row['date'] . "</h5>" .
"<h1 class='content_headers'>" . $title = $row['title'] . "</h1>" .
"<article>" . $content = $row['content'] . "</article>" …Run Code Online (Sandbox Code Playgroud) 我有一个div元素有3个类:
<div class='captcha_article captcha_email captcha_register'></div>
Run Code Online (Sandbox Code Playgroud)
例如,如何在不影响div中其他两个类的样式的情况下定位第三个类?
另外,如果我有4个课程,如何在不使用last-child属性的情况下定位最后一个课程?将:nth-child适用于这里?