I am creating a student fee management form. My fee_inventory table includes fields id, fee_name, amount, fee_type, class, session
fee_type field can be monthly, quarterly, halfyearly, annually
Now I want to display a table where for each fee_name there will be 12 months
If fee_type='quarterly' rowspan='3' If fee_type='halfyearly' rowspan='6' and for annually rowspan will be 12
my php code is given below which is printing an abnormal table. Once it gets rowspan=3 it should not print the particular for the next two values of $i.
Help me in getting it correct
<?php
echo '<table border="2"><tr>';
while($row4=mysql_fetch_array($result4))
{
echo '<td>'.$row4[1].'</td>';
}
echo '</tr>';
$data = array();
while( $row5 = mysql_fetch_array($result5) )
$data[] = $row5;
for($i=1;$i<=12;$i++)
{
echo '<tr>';
foreach ( $data as $row5 )
{
if($row5[3]=='monthly')
echo '<td>'.$row5[3].'</td>';
else if($row5[3]=='quarterly')
echo '<td rowspan="3">'.$row5[3].'</td>';
else if($row5[3]=='halfyearly')
echo '<td rowspan="6">'.$row5[3].'</td>';
else if( $row5[3]=='anually')
echo '<td rowspan="12">'.$row5[3].'</td>';
}
echo '</tr>';
}
echo '</table>';
?>
forloop have to do in this instance? It seems that you're just iterating the$data12 more times than it should be...?