Hello guys,
Working on a stock market table with rates of different currencies.
What I would like to achieve is that i have an array of rates and would like the difference of today and the previous day, and it works, but i'm getting an empty value for the first row, which i dont know how to escape.
while($arr = mysql_fetch_array($sql))
{
if(!is_null($previous) && $previous['euro'] == $arr['euro'])
{
$euro = '';
$usd = '';
}
else
{
$euro = $previous['euro']-$arr['euro'];
$usd = $previous['usd']-$arr['usd'];
$huf = $previous['huf']-$arr['huf'];
if('-'.$arr['euro'] == $euro)
{
$euro_ok = null;
$usd_ok = null;
$huf_ok = null;
}
else
{
$euro_ok = $euro;
$usd_ok = $usd;
$huf_ok = $huf;
}
$data .= '<tr><td style="width: 100px; background-color: #CCC;">'.date("d-M-Y", strtotime($arr['data'])).'</td><td>'.$arr['euro'].'</td><td>'.$this->formatare($euro_ok).'</td><td>'.$arr['usd'].'</td><td>'.$this->formatare($usd_ok).'</td><td>'.$arr['huf'].'</td><td>'.$this->formatare($huf_ok).'</td></tr>';
}
$previous = $arr;
$i++;
}