2010-03-15 42 views
0

我想在論壇部分的邊欄中的外部數據庫中顯示數據饋送。如何在VBulletin 4論壇中顯示外部數據庫數據論壇自定義PHP塊?

PHP模塊代碼:

$host = 'db.123.net'; 
$dbUser = 'db49'; 
$dbPass = 'iReVbY'; 
$db = 'db6578h8'; 
mysql_connect("$host", "$dbUser", "$dbPass") or die(mysql_error()); 
mysql_select_db("$db") or die(mysql_error()); 
ob_start(); 
$result = mysql_query("SELECT id, title from abc") or die(mysql_error()); 
while($row = mysql_fetch_array($result)) { 
print"<center>"; 
print "<a href=\"http://abc.com/?id=" . $row['id'] . "\"></a>"; 
print "</center>"; 
} 
$output .= ob_get_contents(); 
return $output; 
ob_end_clean(); 

如何返回數組在側邊欄(論壇部分)一個PHP代碼塊顯示?

請幫我解決這個問題!謝謝..

回答

0

這是解決方案!最後!

$host = 'dbhost.net'; 
$dbUser = 'dboUser'; 
$dbPass = 'pass'; 
$db = 'dbYourDB'; 
mysql_connect("$host", "$dbUser", "$dbPass") or die(mysql_error()); 
mysql_select_db("$db") or die(mysql_error()); 
ob_start(); 
$result = mysql_query("SELECT id, title, expirydate, createdate FROM table WHERE expirydate >= curdate() ORDER BY expirydate ASC limit 20") or die(mysql_error()); 
while($row = mysql_fetch_array($result)) { 
$output .= "<a href=\"http://abc.com/data.aspx?id=" . $row['id'] . "\">$row[title]</a>"; 
$output .= "<br />"; 
$output .= "<br />"; 
} 
$output .= ob_get_contents(); 
return $output; 
ob_end_clean();