Display Problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nishmgopal
Forum Contributor
Posts: 101
Joined: Tue Mar 03, 2009 9:38 am

Display Problems

Post by nishmgopal »

Hi,

I am trying to display $PersonTotal and $JoBTotal as another row but am having difficulty formatting it correctly....

code:

Code: Select all

 
 
$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
wellhole
Forum Newbie
Posts: 16
Joined: Mon Mar 23, 2009 1:38 pm

Re: Display Problems

Post by wellhole »

Again, you'll need to relate how each table links to eachother. If you don't do that, you'll just get a huge mess. Read up on cartesian products.
Post Reply