richie19rich77 Posted October 14, 2006 Share Posted October 14, 2006 Hi EveryoneVery new to PHP and anything web related, just a normal VB programmer. Building a sports website that will list league tables, fixtures, percentages and so on. I have built my backend database, but just trying to get some of the basic queries to work.For starters I have a table called ClubsClub_ID Club_Name1 Howard2 Chatham3 RainhamThen I have another table called TeamsTeam_ID Club_ID Team_Name1 1 1st2 1 2nd3 2 1st4 3 1st Now I want to create a dynamic table that displays the "Teams" table, but instead of listing the Club_ID I want it to do a lookup and show the real name of that club. e.g Team_ID 1 would be: Team_ID Club_ID Team_Name1 Howard 1stSorry if it does not make sence, but the problem I have is that I do not no the wording for this kind of function otherwise I could look it up on the internet.I am using Dreamweaver 8.0.2Thanks Link to comment https://forums.phpfreaks.com/topic/23945-display-sql-table-just-query-label-headings-from-different-table/ Share on other sites More sharing options...
richie19rich77 Posted October 15, 2006 Author Share Posted October 15, 2006 Ok I have worked it out, not quite sure if this is the best way,[code]<table border="0"> <tr> <td>Teams_ID</td> <td>RealClub_ID</td> <td>Club_ID</td> <td>Team_ID</td> <td>RealWeekday_ID</td> <td>Weekday_ID</td> <td>Team_Captian</td> </tr> <?php do { ?> <tr> <td><?php echo $row_Team['Teams_ID']; ?></td><?php $Club = $row_Team['Club_ID']; $query_Club = "SELECT * FROM clubs WHERE Club_ID = $Club"; $Club = mysql_query($query_Club, $Medway_Database) or die(mysql_error()); $row_Club = mysql_fetch_assoc($Club);?> <td><?php echo $row_Team['Club_ID']; ?></td> <td><?php echo $row_Club['Club_Name']; ?></td> <td><?php echo $row_Team['Team_ID']; ?></td><?php $Day = $row_Team['Weekday_ID']; $query_Weekday = "SELECT * FROM weekday WHERE Weekday_ID = $Day"; $Weekday = mysql_query($query_Weekday, $Medway_Database) or die(mysql_error()); $row_Weekday = mysql_fetch_assoc($Weekday);?> <td><?php echo $row_Team['Weekday_ID']; ?></td> <td><?php echo $row_Weekday['Day']; ?></td> <td><?php echo $row_Team['Team_Captian']; ?></td> </tr> <?php } while ($row_Team = mysql_fetch_assoc($Team)); ?></table><p> </p><p> </p>[/code]Leaves me with:[quote]Teams_ID RealClub_ID Club_ID Team_ID RealWeekday_ID Weekday_ID Team_Captian 1 1 Anchorians TTC 1 2 Tuesday Jeff Norman 2 1 Anchorians TTC 2 2 Tuesday Sean McMillan 3 1 Anchorians TTC 3 2 Tuesday Roger Sayer 4 1 Anchorians TTC 4 2 Tuesday Gay Turner 5 2 Boxley TTC 1 1 Monady Jim Bradford 6 2 Boxley TTC 2 1 Monady Steve Neilson 7 3 B.T Engineers 1 1 Monady Melvyn Curtis 8 4 Chatham TTC Ark Royal 2 Tuesday Dave Macaulay 9 4 Chatham TTC Black Prince 2 Tuesday Mathew Connell 10 4 Chatham TTC Coventry 2 Tuesday Martin Birley [/quote] Link to comment https://forums.phpfreaks.com/topic/23945-display-sql-table-just-query-label-headings-from-different-table/#findComment-108914 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.