Trying to add PHP to my forums
I am trying to add this simple PHP code to scrape the latest currency to my forums. What is the best and easiest way? thanks,
<?php
$today = date('Y-m-d');
$con = mysql_connect('localhost', 'user', 'passwd'); # please put appropriate values here
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("currency", $con); # please replace 'mydb' with your database name.
$query = "SELECT cur_rate FROM currency WHERE cur_date = '$today' AND cur_code = 'PHP'";
$result = mysql_query($query)
or die(mysql_error());
$row = mysql_fetch_array( $result );
$php = $row['cur_rate'];
echo $php;
?>
i tried to write a plugin and used global_start as the hook and it worked one time and then went away and never came back. PLEASE HELP!
also, while i am at it, how would one format the number that it outputs so it is only 2 decimal places?
thanks in advance
|