我想在论坛部分的侧边栏中显示来自外部数据库的数据Feed。
PHP Block Code:
$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 :(得分: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();