views:

205

answers:

1

Hi guys! I want to display data feed from an external database in a sidebar in the forums section.

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(); 

How do I return an array to display in a PHP block in the sidebar (forums section)?

Please help me out of this! Thank you..

A: 

Here is the solution! Finally!

$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();
ThinkCode