nishmgopal Posted March 22, 2009 Share Posted March 22, 2009 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 More sharing options...
Maq Posted March 22, 2009 Share Posted March 22, 2009 </pre> <table> //put your header tags here while ($row=mysql_fetch_array($result)) { //columns and rows here just echo your $row results within the rows and columns } </ Link to comment https://forums.phpfreaks.com/topic/150598-displayin-results-of-sql-query/#findComment-791048 Share on other sites More sharing options...
nishmgopal Posted March 22, 2009 Author Share Posted March 22, 2009 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... Link to comment https://forums.phpfreaks.com/topic/150598-displayin-results-of-sql-query/#findComment-791060 Share on other sites More sharing options...
Maq Posted March 22, 2009 Share Posted March 22, 2009 So change the tag values and values in your rows to the desired values from the result set. Link to comment https://forums.phpfreaks.com/topic/150598-displayin-results-of-sql-query/#findComment-791064 Share on other sites More sharing options...
nishmgopal Posted March 22, 2009 Author Share Posted March 22, 2009 thanks for your help... Link to comment https://forums.phpfreaks.com/topic/150598-displayin-results-of-sql-query/#findComment-791091 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.