How to add row in loop
Posted: Wed Nov 17, 2010 6:46 am
Hi
I have trying to add total no of Marks in the last row of semester. but unable to add the row through loop.data are came from marks tb.
code are like
<?php
$sql="select SubjectCode,Subject,Theory,Practical,Total,Elective,SemId from subjectallocationtb where CourseId='$cours' order by PaperCode";
//echo $sql;
$rs=mysql_query($sql) or die (mysql_error());
$i=1;
$Lastid = "0";
$id = "";
while($count=mysql_fetch_array($rs))
{
if($count['SemId'] != $Lastid)
{
//echo "hai".$Lastid;
//echo $count['SemId'] ;
echo "<tr><td colspan='3'>$count[SemId]-Trimester</td><td></td><td></td></tr>";
//echo $Lastid;
//echo $count['SemId'] ;
$Lastid = $count['SemId'];
//echo $Lastid;
}
echo "hi";
//echo $Lastid;
//echo $count['SemId'] ;
$sql=mysql_query("select ObtMarks from studentmarkstb where RegistrationNo='$regd' and Course='$cours' and SubjectCode='$count[SubjectCode]'");
while($b=mysql_fetch_array($sql))
{
$marks = $b[ObtMarks];
}
//echo $marks;
echo "<tr><td>$i</td><td>$count[Subject]</td><td>100</td><td>40</td><td>$marks</td></tr>";
if($Lastid!= $id)
{
echo "total";
}
$i++;
//echo $count['SemId'];
//echo $Lastid;
}
//$rs=mysql_num_rows($sql);
?>
Find the attached file.............
thanks
I have trying to add total no of Marks in the last row of semester. but unable to add the row through loop.data are came from marks tb.
code are like
<?php
$sql="select SubjectCode,Subject,Theory,Practical,Total,Elective,SemId from subjectallocationtb where CourseId='$cours' order by PaperCode";
//echo $sql;
$rs=mysql_query($sql) or die (mysql_error());
$i=1;
$Lastid = "0";
$id = "";
while($count=mysql_fetch_array($rs))
{
if($count['SemId'] != $Lastid)
{
//echo "hai".$Lastid;
//echo $count['SemId'] ;
echo "<tr><td colspan='3'>$count[SemId]-Trimester</td><td></td><td></td></tr>";
//echo $Lastid;
//echo $count['SemId'] ;
$Lastid = $count['SemId'];
//echo $Lastid;
}
echo "hi";
//echo $Lastid;
//echo $count['SemId'] ;
$sql=mysql_query("select ObtMarks from studentmarkstb where RegistrationNo='$regd' and Course='$cours' and SubjectCode='$count[SubjectCode]'");
while($b=mysql_fetch_array($sql))
{
$marks = $b[ObtMarks];
}
//echo $marks;
echo "<tr><td>$i</td><td>$count[Subject]</td><td>100</td><td>40</td><td>$marks</td></tr>";
if($Lastid!= $id)
{
echo "total";
}
$i++;
//echo $count['SemId'];
//echo $Lastid;
}
//$rs=mysql_num_rows($sql);
?>
Find the attached file.............
thanks