Jump to content

displayin results of sql query


nishmgopal

Recommended Posts

Hi Guys,

 

Below is part of my code, and I wanted to know how I can display the results as a html table with Job_Name, Skill_Name, Person Name, Skill_Name and Total as the columns

 

$sql= "SELECT
     Person_ID.Person_Name, Person_Skill.Skill_name, (Person_Skill.Score-ID_Table.Weight) AS total, Job_ID.Job_Name, ID_Table.Skill_Name
FROM
     Job_ID
     JOIN ID_Table
        USING (Job_ID)
     JOIN Person_Skill
         USING (Skill_Name)
     JOIN Person_ID
         USING (Person_ID)
  ORDER BY
     total
DESC";

$result = mysql_query($sql)
  or die ("Couldn't execute query.");

while ($row=mysql_fetch_array($result))
{
       
}

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/150598-displayin-results-of-sql-query/
Share on other sites

I tried this:

 

$sql= "SELECT
     Person_ID.Person_Name, Person_Skill.Skill_name, (Person_Skill.Score-ID_Table.Weight) AS total, Job_ID.Job_Name, ID_Table.Skill_Name
FROM
     Job_ID
     JOIN ID_Table
        USING (Job_ID)
     JOIN Person_Skill
         USING (Skill_Name)
     JOIN Person_ID
         USING (Person_ID)
  ORDER BY
     total
DESC";

$result = mysql_query($sql)
  or die ("Couldn't execute query.");
while ($row=mysql_fetch_array($result))
{
    $tblRows .= "<tr>";
$tblRows .= "<td>{$row['Job_Name']}</td>";
    $tblRows .= "<td>{$row['Skill_Name']}</td>";
    $tblRows .= "<td>{$row['Weight']}</td>";
$tblRows .= "<td>{$row['Score']}>/td>";
    $tblRows .= "</tr>\n";
  
  }

echo "<table width=\"200\" border=\"1\">\n";
echo "<tr><th>Job_Name</th><th>Skill</th><th>Weight</th></tr>\n";
echo "$tblRows";
echo "</table>\n";

 

and i got:

 

Job_Name Skill Weight

Manager Java >/td>

Manager Java >/td>

Manager C >/td>

Manager C# >/td>

 

 

But I want the Job Name, Person Name, Skill Name, Weight and Score...

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.