|
Hi All:
I am trying to display table info into the webpage. However, the loop i am using is displaying the information twice. For example:
Instituition -->Course-->Name-->Credits-->Date-->Status
XYZ School Eng101 English 3 01/04 TR
Eng101 English 3 01/04 TR
Php Code is as follow:
<?php
$query = "SELECT * from transfer_credits WHERE ssn='$ssn' ORDER BY date1";
$result = mysqli_query($link_id, $query);
if (!result) printf("SQL Syntax: %s\n", mysqli_error($link_id));
$i=0;
$pl_credits = 0;
while($row = mysqli_fetch_assoc($result))
{
$transfers[$row['institute']][$i]=$row['course_name'];
$date1[$i]=$row['date1'];
$credits[$i]=$row['credits'];
$status[$i]=$row['status'];
$course_id[$i++]=$row['course_id'];
}
if ($i > 0)
{
print "<tr><td><table class=border width=100% cellspacing=1 cellpadding=1>";
print "<tr class=header1><th colspan=6 align=center>Transfer Credits</th></tr>";
print "<tr class=header2><th>Institution<th>Course<th>Name<th >Credits<th>Date<th>Status";
foreach ($transfers as $key1 => $value1)
{
print "<tr class=course><td>".strformat($key1);
$i=0;
foreach ($transfers[$key1] as $key2 => $value2)
{
if ($i++ != 0) print "<tr class=course><td>";
print "<td><font size=-1>$course_id[$key2]";
print "<td><font size=-1>".strformat($value2);
print "<td align=center><font size=-1>$credits[$key2]";
print "<td><font size=-1>".dateformat($date1[$key2]);
print "<td align=center><font size=-1>$status[$key2]TR";
$pl_credits += $credits[$key2];
}
}
print "<tr class=header2><th><th><th align=right><font size=-1>Total Transfer Credits<th><font size=-1>$pl_credits<th><th></table></td></tr>";
}
?>
Can anyone fix this problem?
|