displayin results of sql query

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

displayin results of sql query

Post 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
User avatar
aditya2071990
Forum Contributor
Posts: 106
Joined: Thu May 22, 2008 11:30 am
Location: Hyderabad, India
Contact:

Re: displayin results of sql query

Post 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...
Post Reply