Crustyfur Posted July 3, 2007 Share Posted July 3, 2007 Hi, I need the second query to display its results based on the 'townid' from the first query. I am not sure how to pass it. The page variable is '$countyid'. As you can see I have used a 'townid' of '11' as an example if I dont make any sense. <?php <table cellpadding=\"10\">"; $result = $db->sql_query("SELECT * FROM ft_clubs_town WHERE countyid = '$countyid' ORDER BY town ASC"); $counter = 0; echo "<tr><td valign=\"top\" align=\"left\">"; while($row = $db->sql_fetchrow($result)) { if($counter>25) { echo "</td><td valign=\"top\">"; $counter = 0; } echo $row["town"]; echo "<br />"; $result2 = $db->sql_query("SELECT club FROM ft_clubs WHERE townid = '11' ORDER BY club ASC"); while($row2 = $db->sql_fetchrow($result2)) { echo $row2["club"]; echo "<br />"; } echo "<br />"; $counter++; } echo "</tr>"; echo "</table> ?> Quote Link to comment Share on other sites More sharing options...
no_one Posted July 3, 2007 Share Posted July 3, 2007 I'll assume each row grabbed from the the first query has an id? Something like <?php $town_id = $row['id'] $result2 = $db->sql_query("SELECT club FROM ft_clubs WHERE townid = '$town_id' ORDER BY club ASC"); ?> Perhaps? Quote Link to comment Share on other sites More sharing options...
Crustyfur Posted July 3, 2007 Author Share Posted July 3, 2007 Spot on thanks no_one. 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.