|
nishmgopal
|
Mar 24 2009, 05:43 PM
Post #1
|
|
- Posts:
- 2
- Group:
- Members
- Member
- #73
- Joined:
- Mar 24, 2009
|
Hi,
I am trying to display $PersonTotal and $JoBTotal as another row but am having difficulty formatting it correctly....
code:
- Code:
-
$sql= "SELECT Person_Name, b.Skill_Name, c.id, ( d.Score - c.Weight ) AS total, d.Score, c.Weight, e.Job_Name FROM Person_ID a JOIN Skill_ID b JOIN ID_Table c ON b.Skill_ID = c.Skill_ID JOIN Job_ID e ON c.Job_ID = e.Job_ID LEFT OUTER JOIN Person_Skill d ON a.Person_ID = d.person_Id AND b.Skill_ID = d.Skill_ID WHERE e.Job_Name = '{$_SESSION[Job_Name]}' ORDER BY Person_Name, Skill_Name"; $result1 = mysql_query($sql) or die ("Couldn't execute query."); $PrevPersonName = ""; $personFound = false; $PersonTotal = 0; $JobTotal = 0; while ($row=mysql_fetch_array($result1)) { if ($PrevPersonName != $row['Person_Name']) { if ($personFound) { echo "</table>\n"; } $personFound = true; $PersonTotal = 0; $JobTotal = 0; $PrevPersonName = $row['Person_Name']; $JobName=$row['Job_Name']; echo "<font color='#F88DIF'><strong>$PrevPersonName as a $JobName:</font>"; echo "<table width=\"200\" border=\"1\">\n"; echo "<hr>"; echo "<tr><th nowrap=\"nowrap\" bgcolor=\"#4096ee\"><strong>Skills Required</th><th bgcolor=\"#4096ee\">Weight</th><th bgcolor=\"#4096ee\">Actual Score</th><th bgcolor=\"#4096ee\">Difference</th></tr>\n"; } $PersonTotal += $row['Score']; $JobTotal += $row['Weight']; echo "<tr>"; echo "<td align='center'>{$row['Skill_Name']}</td>"; echo "<td align='center'>{$row['Weight']}</td>"; echo "<td align='center'>{$row['Score']}</td>"; echo "<td align='center'>{$row['total']}</td>"; echo "</tr>\n"; } echo "</table>\n";
Thanks
|