Still new to php..number formatting query
Posted: Fri Jan 08, 2010 11:17 am
Hello all
Ok so I have read the manual for number formatting but i can't think of how to implement this into my code.
Basically what i am doing is retrieving data from a mysql database which then displays my currency data as 0.331904
What I have been trying to do is getting it to display £0.33.
The results populate a table that has this code
I can't think of where to put the number_format code. I have tried various places but it doesn't work.
I'm sure I am missing something simple. Can someone point me in the right direction?
Many thanks and kind regards
Peter
Ok so I have read the manual for number formatting but i can't think of how to implement this into my code.
Basically what i am doing is retrieving data from a mysql database which then displays my currency data as 0.331904
What I have been trying to do is getting it to display £0.33.
The results populate a table that has this code
Code: Select all
//Table to hold the data
echo "<table id='results_table' class='tablesorter'>";
echo "<thead>";
echo "<tr>";
echo "<th>Account</th>";
echo "<th>Campaign</th>";
echo "<th>Adgroup</th>";
echo "<th>Impressions</th>";
echo "<th>Clicks</th>";
echo "<th>CTR</th>";
echo "<th>CPC</th>";
echo "<th>Cost</th>";
echo "<th>Avg_Position</th>";
echo "<th>Conversions</th>";
echo "<th>Conversions_mpc</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "<tr onmouseover=\"mouse_event(this, 'hlt');\" onmouseout=\"mouse_event(this, '');\">";
//echo "<td>{$row['date']}</td>";
echo "<td>{$row['account']}</td>";
echo "<td>{$row['campaign']}</td>";
echo "<td>{$row['adgroup']}</td>";
echo "<td>{$row['impressions']}</td>";
echo "<td>{$row['clicks']}</td>";
echo "<td>{$row['ctr']}%</td>";
echo "<td>{$row['cpc']}</td>";
echo "<td>{$row['cost']}</td>";
echo "<td>{$row['avg_position']}</td>";
echo "<td>{$row['conversions']}</td>";
echo "<td>{$row['conversions_mpc']}</td>";
echo "</tr>";
}
?>I'm sure I am missing something simple. Can someone point me in the right direction?
Many thanks and kind regards
Peter