I have a database table which allows users to save their progress (of what does not matter
I have got this sorted and adding to the database is fine. What I am trying to do is output a basic bar chart over a course of 365 days.
I thought the easiest way was to have <DIV>s that height are controled by the value of the data in the table. But, I also need days in which no data was saved to show up as blank.
This is the code I came up with which is messy and not great, and not sure works:
(BTW - this is just the code for the bars, the rest of the graph is fine)
Code: Select all
$i = 0;
while($i < 365)
{
while($bar_row = mysql_fetch_assoc($result))
{
$yesterday = mktime(0,0,0,date("m"),date("d")-$i,date("Y"));
if($bar_row['date'] == date("Y-m-d", $yesterday))
{
?>
<div style=" <?php if(date("Y-m-d") == $bar_row['date']) {echo "background-color:#0000CC";}else{echo "background-color:#FF0000";} ?>; height:<?php echo forcenumeric($bar_row['bench']); ?>px; width:2px;"></div>
<?php
}
else
{
?>
<div style="background-color:#000000; height:1px; width:2px;"></div>
<?php
}
}
$i ++;
}Need help!
Can anyone offer some help/input on this?