Page 1 of 1

displayin results of sql query

Posted: Sun Mar 22, 2009 1:30 pm
by nishmgopal
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

Code: Select all

 
$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

Re: displayin results of sql query

Posted: Sun Mar 22, 2009 2:45 pm
by aditya2071990
You can refer to the data inside $row like this: $row['Person_name'], so statements like

Code: Select all

 
echo '<td>Name of the Person:'.$row['Person_name'].'</td>';
 
should do the trick... and because the statement is in a while loop, all your data will be displayed in whatever html format you write...