whughesiii
MIS
I have a web page I am developing for personal use maintaining backup logs. I have a mysql table called volumes which has fields (index_num, volume, last_bu) and another table called backup_log with fields (index_num, volume (which is a reference to the index_num of volumes), snapshot_num and bu_date). Part of my function is working where it displays an HTML table showing dates from a date range pulled from backup_log and displayed as seperate columns. For example:
Volume | 2011-08-08 | 2011-08-09 | 2011-08-10 etc...
What I want to do, is for each volume, display the snapshot_num in the column represented by that date. For example:
Volume | 2011-08-08 | 2011-08-09 | 2011-08-10 etc...
Server1| 800 | 801 | 802 etc..
Here is what I have in my code right now:
This is not really urgent, but any help is greatly appreciated. I am thinking that my logic relating to the foreach is wrong but I am not sure. It has been a long time since I have done anything like this.
Volume | 2011-08-08 | 2011-08-09 | 2011-08-10 etc...
What I want to do, is for each volume, display the snapshot_num in the column represented by that date. For example:
Volume | 2011-08-08 | 2011-08-09 | 2011-08-10 etc...
Server1| 800 | 801 | 802 etc..
Here is what I have in my code right now:
Code:
function san_bkup()
{
$q = "SELECT bu_date FROM backup_log WHERE bu_date BETWEEN '2011-08-08' AND '2011-08-14' GROUP BY bu_date";
$r = mysql_query($q);
$i = 0;
?>
<html><title>Backup Log</title></head>
<p align="center"><font size="4" color="blue">Backup Log</font></p>
<table align="center" border="2" width="800">
<tr>
<td align="center">Volume</td>
<?php
while($row = mysql_fetch_array($r)){
echo '<td align="center">' . $row[$i] . '</td>';
}
?>
</tr>
<?php
$q1 = "SELECT * FROM backup_log as s, volumes as v WHERE bu_date BETWEEN '2011-08-08' AND '2011-08-14' AND s.volume = v.volume";
$r2 = mysql_query($q1);
$i=1;
while($row2 = mysql_fetch_array($r2)){
echo '<tr><td>' . $row2['volume'] . '</td>';
foreach($row2 as $row){
$i=2;
echo '<td>' . $row2[$i] . '</td>';
$i++;
}
}
?>
</table>
</html>
<?php
}
?>
This is not really urgent, but any help is greatly appreciated. I am thinking that my logic relating to the foreach is wrong but I am not sure. It has been a long time since I have done anything like this.