It is a simple graphing program based on 4 quarters. Each quarter has 13 weeks, for a 52 week year. I have highlighted in blue what is blowing up. I have a variable $numrs that is equal to 35. I don't know why it doesn't think there is a row 34. Any help would be great. Thanx
$db = mysql_connect("localhost", "root");
mysql_select_db ("graph") or die ("Sorry, database Problems. Please try again.");
$result = mysql_query ("SELECT * FROM argraph order by week desc") or die ("Sorry no results. Please try again.");
$numrs = mysql_num_rows($result);
for ($i=0; $i<$numrs; $i++) {
$week = mysql_result($result,$i, "week");
$amount = mysql_result($result,$i, "amount");
$mySecondGraph->AddValue("$week","$amount");
}
mysql_close($db);
$mySecondGraph->SetShowCountsMode(1);
$mySecondGraph->SetBarWidth(10);
$mySecondGraph->SetBorderColor("#333333");
$mySecondGraph->SetBarBorderWidth(1);
$mySecondGraph->SetGraphWidth(220);
$mySecondGraph->BarGraphHoriz();
print "
</td>
<td width=50%>
<table border=0 width=100%>";
$db = mysql_connect("localhost", "root");
mysql_select_db ("graph") or die ("Sorry, database Problems. Please try again.");
$result = mysql_query ("SELECT * FROM argraph order by week desc") or die ("Sorry no results. Please try again.");
$numrs = mysql_num_rows($result);
$firstqavg = 0;
$secondqavg = 0;
$thirdqavg = 0;
if($numrs >= 13){
for ($i=0; $i<=13; $i++) {
$amount = mysql_result($result,$i, "amount");
$firstqavg = $amount + $firstqavg;
}//end of for
$firsttotal = $firstqavg / 13;
}//end of if
else {
$remainder = fmod($numrs, 13);
for ($i=0; $i<=$numrs; $i++) {
$amount = mysql_result($result,$i, "amount");
$firstqavg = $amount + $firstqavg;
}//end of for
$firsttotal = $firstqavg / $remainder;
}//end of else
print "<tr>
<td align=center width=100%>1st Quarter Averages: $firsttotal</td>
</tr>";
if($numrs >= 26){
for ($i=14; $i<=26; $i++) {
$amount = mysql_result($result,$i, "amount");
$secondqavg = $amount + $secondqavg;
}//end of for
$secondtotal = $secondqavg / 13;
}//end of if
else {
$remainder = fmod($numrs, 13);
for ($i=14; $i<=$numrs; $i++) {
$amount = mysql_result($result,$i, "amount");
$secondqavg = $amount + $secondqavg;
}//end of for
$secondtotal = $secondqavg / $remainder;
}//end of else
print "<tr>
<td align=center width=100%>2nd Quarter Averages: $secondtotal</td>
</tr>";
if($numrs >= 39){
for ($i=27; $i<=39; $i++) {
$amount = mysql_result($result,$i, "amount");
$thirdqavg = $amount + $thirdqavg;
}//end of for
$thirdtotal = $thirdqavg / 13;
}//end of if
else {
$remainder = fmod($numrs, 13);
for ($i=27; $i<=$numrs; $i++) {
$amount = mysql_result($result,$i, "amount");
$thirdqavg = $amount + $thirdqavg;
}//end of for
$thirdtotal = $thirdqavg / $remainder;
}//end of else
print "<tr>
<td align=center width=100%>3rd Quarter Averages: $thirdtotal</td>
</tr>
<tr>
<td align=center width=100%>4th Quarter Averages: </td>
</tr>
</table>
</td>
</tr>
</table>";
mysql_close($db);
?>