2013-05-28 36 views
0

大家好我是PHP和MySQL的新手,但我需要一個簡單的(可能)sql查詢,它將從一個類別中選擇所有已發佈的鏈接(例如帶有ID 6號)Pligg CMS的SQL查詢只選擇來自一個類別的所有已發佈的新聞

現在我有一個從所有類別

<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

找到了正確的查詢,謝謝!

<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>