I need help..i have a while loop inside a while loop..
and it displays repeated values.can anyone help me..thanks in advance...
the output should be:
1
2
3
4
5
but it displays:
1
2
3
4
5
1
2
3
4
5
hope you can help me....
and it displays repeated values.can anyone help me..thanks in advance...
Code:
if ($_REQUEST['sem']==2){
$result="select g.* from grades as g, prospectus as p where g.idno='".$_REQUEST['idno']."' and g.course='".$_REQUEST['course']."' and g.year='".$_REQUEST['year']."' and g.sem=1 and g.syear='".$_REQUEST['syear']."' and g.remarks='failed' and g.subid=p.prerequisite1";
$rsq=mysql_query($result);
if(mysql_num_rows($rsq)>=1){//if student exist in first sem..evaluate grades for second sem
while($grade=mysql_fetch_array($rsq)){
$grades=$grade['subid'];
//echo "".$grades."<br />";
$race = mysql_query("SELECT DISTINCT subid FROM prospectus
WHERE prospectus.prerequisite1
NOT IN (
SELECT prospectus.subid
FROM prospectus
WHERE prospectus.subid='".$grades."'
) and prospectus.sem=2
");
while($sub_row = mysql_fetch_array($race)){
//echo "".$sub_row['subid']."<br />";
$result2="select * from subject where subid='".$sub_row['subid']."' order by subid ASC limit 0,1";
$rsq2=mysql_query($result2);
while ($r2=mysql_fetch_array($rsq2)){
echo "<tr>";
echo "<td><input type=\"hidden\" name=\"subid[]\" value=\"".$r2['subid']."\"/>".$r2['subcode']."</td><td>".$r2['subname']."</td><td>".$r2['subdesc']."</td><td>".$r2['units']."</td></tr>";
}
}
}
}
1
2
3
4
5
but it displays:
1
2
3
4
5
1
2
3
4
5
hope you can help me....
Comment