JTapp Posted February 17, 2008 Share Posted February 17, 2008 I just don't know if this is complicated or not. Being that I've spent HOURS on it.. but I'm aslo a beginner... I need to display the results of a database in a particular format. I have two tables to pull from. The problem is I need the upper half of my webpage to display the results from one table and the bottom half of my webpage to display the results of the other table and I'm using a $metode function to query everything. Here is my immature and totally gutted/ code: //query details $query = mysql_query("SELECT tblLodges.strLodgeName, tblOfficers.strFirstName, tblOfficers.strLastName FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID WHERE $metode LIKE '%$search%' LIMIT 0, 50"); while ($row = @mysql_fetch_array($query)) { $variable1=$row["strLodgeName"]; $variable2=$row["strLodgeID"]; $variable3=$row["strDistrictName"]; $variable4=$row["strLodgeLocationCity"]; $variable5=$row["strLodgeLocationZip"]; $variable6=$row["strLodgeCounty"]; $variable7=$row["strFirstName"]; $variable8=$row["strLastName"]; //table layout for results print ("<tr>"); echo "<td class=\"td_id\"><h3>$variable1</h3></td>\n"; echo "<td class=\"td_id\">$variable2</td>\n"; echo "<td class=\"td_id\">$variable3</td>\n"; print "<td class=\"td_id\">$variable4</td>\n"; print "<td class=\"td_id\">$variable5</td>\n"; print "<td class=\"td_id\">$variable6</td>\n"; print ("</tr>"); } ?> <p class="style1">Roster of Officers </p> <hr width=75% align=center size=4> <p> <?php echo "<table border='1'> <tr> <th>Officer First Name</th> <th>Officer Last Name</th> <th>Officer Business Phone</th> <th>Officer Email</th> </tr>"; { echo "<tr>"; echo "<td>" . $row['strFirstName'] . "</td>"; echo "<td>" . $row['strLastName'] . "</td>"; echo "<td>" . $row['BusinessPhone'] . "</td>"; echo "<td>" . $row['PersEmail'] . "</td>"; echo "</tr>"; } echo "</table>"; ?> Quote Link to comment Share on other sites More sharing options...
harristweed Posted February 17, 2008 Share Posted February 17, 2008 try something like this: <?php $query = mysql_query("SELECT tblLodges.strLodgeName, tblOfficers.strFirstName, tblOfficers.strLastName FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID WHERE $metode LIKE '%$search%' LIMIT 0, 50"); $results=mysql_query($query); echo "<table border='1'> <tr> <th>Officer Lodge Name</th> <th>Officer Lodge ID</th> <th>Officer City</th> <th>Officer zip</th> <th>Officer County</th> <th>Officer First</th> <th>Officer last</th> </tr>"; while ($row = mysql_fetch_array($query)) { $variable1=$row["strLodgeName"]; $variable2=$row["strLodgeID"]; $variable3=$row["strDistrictName"]; $variable4=$row["strLodgeLocationCity"]; $variable5=$row["strLodgeLocationZip"]; $variable6=$row["strLodgeCounty"]; $variable7=$row["strFirstName"]; $variable8=$row["strLastName"]; //table layout for results print ("<tr>"); echo "<td class=\"td_id\"><h3>$variable1</h3></td>\n"; echo "<td class=\"td_id\">$row[strLodgeID]</td>\n"; echo "<td class=\"td_id\">$row[strDistrictName]</td>\n"; print "<td class=\"td_id\">$row[strLodgeLocationCity]</td>\n"; print "<td class=\"td_id\">$row[strLodgeLocationZip]</td>\n"; print "<td class=\"td_id\">$row[strLodgeCounty]</td>\n"; print ("</tr>"); } ?> <p class="style1">Roster of Officers </p> <hr width=75% align=center size=4> <p> <?php echo "<table border='1'> <tr> <th>Officer First Name</th> <th>Officer Last Name</th> <th>Officer Business Phone</th> <th>Officer Email</th> </tr>"; while ($row = mysql_fetch_array($query)) { echo "<tr>"; echo "<td>" . $row['strFirstName'] . "</td>"; echo "<td>" . $row['strLastName'] . "</td>"; echo "<td>" . $row['BusinessPhone'] . "</td>"; echo "<td>" . $row['PersEmail'] . "</td>"; echo "</tr>"; } echo "</table>"; ?> Quote Link to comment Share on other sites More sharing options...
JTapp Posted February 17, 2008 Author Share Posted February 17, 2008 It's trying to work. Here is the link to see the results http://www.la-mason.com/results11.php I know its trying because there are two Table 2 records that map to the Table 1 field DenverColorado ("strLodgeName"). It's just not displaying the rest of the information... Does that make sense? Quote Link to comment Share on other sites More sharing options...
JTapp Posted February 17, 2008 Author Share Posted February 17, 2008 Here is my latest code - it is displaying Table 2 nicely in a table. However, I need Table 1 data to be displayed at the top of the page and not in a table. Nothing is coming up... $query = mysql_query("SELECT tblLodges.strLodgeName, tblLodges.intLodgeNumber, tblLodges.strDistrictName, tblLodges.strLodgeLocationCity, tblLodges.strLodgeLocationZip, tblLodges.strLodgeCounty, tblOfficers.strFirstName, tblOfficers.strLastName, tblOfficers.BusinessPhone, tblOfficers.PersEmail FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID WHERE $metode LIKE '%$search%' LIMIT 0, 50"); $results=mysql_query($query); { $variable1=$row["strLodgeName"]; $variable2=$row["intLodgeNumber"]; $variable3=$row["strDistrictName"]; $variable4=$row["strLodgeLocationCity"]; //table layout for results print ("<tr>"); print ("<td>$variable1</td>"); print ("<td>$variable2</td>"); print ("<td>$variable3</td>"); print ("<td>$variable4</td>"); print ("</tr>"); } echo "<table border='1'> <tr> <th>Officer First</th> <th>Officer Last</th> <th>Officer Business Phone</th> <th>Officer Email</th> </tr>"; while ($row = mysql_fetch_array($query)) { $variable1=$row["strFirstName"]; $variable2=$row["strLastName"]; $variable3=$row["BusinessPhone"]; $variable4=$row["PersEmail"]; //table layout for results print ("<tr>"); echo "<td class=\"td_id\"><h3>$variable1</h3></td>\n"; echo "<td class=\"td_id\"><h3>$variable2</h3></td>\n"; echo "<td class=\"td_id\"><h3>$variable3</h3></td>\n"; echo "<td class=\"td_id\"><h3>$variable4</h3></td>\n"; echo ("</tr>"); } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.