i have one php page in which I have two loops in place. this loop is used to retrieve data from database column and print in the form of a row group by stud_no column.
here is a code:
<?php
$link=mysql_connect("localhost","xyz","toor") or die("Cannot Connect to the database!");
mysql_select_db("dbase",$link) or die ("Cannot select the database!");
$query2="SELECT stud_no FROM fees_master ORDER BY stud_no ;";
$resource2=mysql_query($query2,$link);
$i=1;
while($res=mysql_fetch_array($resource2)) {
$lsd=$res[0];
$query="SELECT stud_no,inst_amt FROM fees_master WHERE stud_no LIKE $lsd ;";
$resource=mysql_query($query,$link);
echo"<table align=\"center\" border=\"0.5\"> <tr>";
while($result=mysql_fetch_array($resource)){
echo "<td>".$i."</td>,";
echo "<td>".$result[0].",</td>";
echo "<td>".$result[1].",</td>,";
if($result[0]!==$lsd)
{
echo"</tr></table>";
break;
}
}
}
?>
after running this code I am getting this output:
http://i.stack.imgur.com/qLvE5.png
please help. I want to print each distinct line only once.