我自己也嘗試了從外部直接連到數據機庫來實現" 最新文章"的block script 如下:
$host = 'localhost';
$user = 'root';
$password = '';
$mydatabase = 'blog';
$table1 = 'blog_articles_text';
//$table3 = 'blog_articles';
$table2 = 'blog_blogs';
$connect = mysql_connect($host, $user, $password);
function aid($artid){
mysql_select_db($mydatabase);
if($resultid2=mysql_query($listall2, $connect)){
$listall2="SELECT blog_id from blog_articles where id=$gaid order by date";
while( $row=mysql_fetch_row($resultid2)){
$artid = "&blogId=".$row["blog_id"]."";
}
}
return $artid;
}
if(!$connect) {
die("Cannot connect to $host using $user");
} else {
mysql_select_db($mydatabase);
$listall = "SELECT DISTINCT* from blog_articles_text order by article_id desc";
//$listall2 = "SELECT DISTINCT blogId from blog_articles order by date desc";
if($resultid=mysql_query($listall, $connect)){
while( $row=mysql_fetch_array($resultid)){
$text="".$row["normalized_text"]."";
$gaid = "".$row["article_id"]."";
print "<tr><td><a href='../blog/index.php?op=ViewArticle&articleId=$gaid".aid($artid)."' target=_blank>".$row["topic"]."</a></td></tr><tr><td>".cutStr($text)."</td></tr>";
}
//}
} mysql_close($connect);
}
但output出來的hyperlink 能夠對應article id 但偏偏不能夠對應blog id ><"
我想應該是sql statement 的問題,,,
各位有沒好的修改建議...謝了