I am trying to setup an application availability report, I have an array of with app names in it and a number. I am going through the list and finding the duration of issues for each one and saving it a corresponding array and then doing a calculation on it. I try to print it out to a table but no dice. I have my test echos and for loops still in there and I get a the app array printed out but inside the while look doesn't execute and I can't pinpoint why. Thanks for the help and I can answer questions about it. I am going to put a month/year form input at the bottom with a submit button that calls this same page back.
<?php
$applist = array('default1','default2','default3');
$numofapps = 3;
$i=0;
$downtime;
if($_POST['submitted']==1)
{
$month = $_POST['startmonth'];
}
else {
$month = date("m");
}
echo "<br />";
switch ($month){
case 01:
case 03:
case 05:
case 07:
case 08:
case 10:
case 12:
$totaltime = 31 * 1440;
break;
case 04:
case 06:
case 09:
case 11:
$totaltime = 30 * 1440.0;
break;
case 02:
$year = $_POST['startyear'];
if(($year%4)==0)
{
$totaltime = 29 * 1440.0;
}
else {
$totaltime = 28 * 1440.0;
}
break;
}
echo "<br />";
while($numofapps > $i)
{
$query="Select `duration` from `issuetrack` WHERE `app`='" . $applist[$i] . "'";
$result=mysql_query($query);
while($row = mysql_fetch_array($result))
{
echo $downtime[$i];
echo "TEST downtime <br />";
echo $row[$i];
echo "ETST DURATION <br />";
$downtime[$i]+=$row['duration'];
}
$appavail[$i]=($downtime[$i] / $totaltime) * 100;
$i++;
echo "<br />";
}
$j=0;
echo "<table border ='1'>";
echo "<tr><th>Application Affected</th><th>Application Availability</th>";
while ($numofapps > $j)
{
echo "<tr><td>";
echo $applist[$i];
echo "</td><td>";
echo $appavail[$i];
echo "</td></tr>";
}
echo "</table>";
?>
echo mysql_error();print out after your$result = mysql_query($query)?$count = mysql_num_rows($query);and thenecho $count;?