Jump to content

[SOLVED] Nested Query


Crustyfur

Recommended Posts

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>
?>

Link to comment
https://forums.phpfreaks.com/topic/58183-solved-nested-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.