大家好我是PHP和MySQL的新手,但是我需要一个简单的(可能)sql查询,它将从一个类别中选择所有已发布的链接(例如ID为6的运动)
现在我有一个查询,可以选择所有类别的所有已发布新闻
<ul>
{php}
$result = mysql_query('SELECT * from ' . table_links . ' WHERE link_status = "published" ORDER BY link_published_date DESC LIMIT 5');
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
printf("<li>%s voturi | <a href='".$this->_vars['my_pligg_base']."/story.php?id=%s'><span style='font-weight:bold'>%s</span></a></li>", $row["link_votes"], $row["link_id"], $row["link_title"]);
}
{/php}
</ul>
提前谢谢!
答案 0 :(得分:0)
找到正确的查询,谢谢!
<ul>
{php}
$result = mysql_query('SELECT * from ' . table_links . ' WHERE link_status = "published" and link_category = 1 ORDER BY link_published_date DESC LIMIT 5');
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
printf("<li>%s voturi | <a href='".$this->_vars['my_pligg_base']."/story.php?id=%s'><span style='font-weight:bold'>%s</span></a></li>", $row["link_votes"], $row["link_id"], $row["link_title"]);
}
{/php}
</ul>