mysql - php while loop table repeating fix -
i have following while loop keep on repeating table each record how fix it? full table repeat each record. every row fetch can add
<table width="1510" border="1" align="center" cellpadding="2" cellspacing="2" class="table table-bordered" > <tbody> <form name="f1"> <? $counter = 1; $total_marks = 0; $total_obtain = 0; while($row_rsdept = mysql_fetch_array($rsdept)) { if($counter === 1) { ?> <tr> <th width="71" rowspan="3" align="center" valign="middle" scope="col"><h4>sr. no</h4></th> <th width="229" align="right" valign="top" scope="col"> </th> <th colspan="8" align="center" valign="middle" scope="col"><h3>detail of marks</h3></th> </tr> <tr> <th rowspan="2" align="left" scope="row"><h4>subject</h4></th> <td colspan="2" align="center"><h4>thoery</h4></td> <td colspan="2" align="center"><h4>practical</h4></td> <td width="134" rowspan="2" align="center" valign="middle"><h4>marks obtain</h4></td> <td width="144" rowspan="2" align="center" valign="middle"><h4>max marks</h4></td> <td width="137" rowspan="2" align="center" valign="middle"><h4>remarks</h4></td> <td width="137" rowspan="2" align="center" valign="middle"><h4>grace marks</h4></td> </tr> <tr> <td width="134">obtained marks</td> <td width="144">total marks</td> <td width="143">obtained marks</td> <td width="153">total marks</td> </tr> <? } ?> <tr> <th align="left" scope="row"> </th> <th align="left" scope="row"><?php echo $row_rsdept['subjects']; ?></th> <td><?php echo $row_rsdept['theoryobtainedmarks']; ?></td> <td><?php echo $row_rsdept['theorytotalmarks']; ?></td> <td><?php echo $row_rsdept['practicalobatinedmarks']; ?></td> <td><?php echo $row_rsdept['practicaltotalmarks']; ?></td> <td align="center" valign="middle"><?php echo $row_rsdept['marksobtained']; ?></td> <td align="center" valign="middle"><?php echo $row_rsdept['maxmarks']; ?></td> <td align="center" valign="middle"><span class="style8"><?php echo $row_rsdept['remarks']; ?></span></td> <td align="center" valign="middle"><?php echo $row_rsdept['gracemarks']; ?></td> </tr> <tr> <th colspan="6" align="right" valign="middle" scope="row"><h4>total</h4></th> <td align="center" valign="middle"><span class="style8"><?php echo $row_rsdept['totalmarks']; ?></span></td> <td align="center" valign="middle">=total of above ( )</td> <td align="center" valign="middle"> </td> <td align="center" valign="middle"> </td> </tr> <?php } ?> <tr> <th colspan="10" align="left" valign="middle" scope="row"> </th> </tr> <tr> <th colspan="8" align="left" valign="middle" scope="row"> </th> <th align="left" valign="middle" scope="row"> </th> <th align="left" valign="middle" scope="row"> </th> </tr> <tr> <th colspan="8" align="left" valign="middle" scope="row"><br></th> <th align="left" valign="middle" scope="row"> </th> <th align="left" valign="middle" scope="row"> </th> </tr> </form> </table>
i tried fix not working me
inside loop need increment counter variable inside loop add line
$counter++;
Comments
Post a Comment