barniegilly Posted August 17, 2011 Share Posted August 17, 2011 Having a thick moment!! what is wrong with my if condition statement. I am looking to have a list of regions and then where the counties id = the regions id the counties show under the counties. Both counties and regions are in a mysql table. This is my php <?php $regions_set = findregion(); while ($regions = mysql_fetch_array ($regions_set)){ echo "<ul>"; echo "<li><a href=\"viewevents.php?url_regionid=" .urlencode ($regions ['region_id']) . "\">" . $regions ['region_description'] . "</a></li>"; $regioncounties_set = findregionscounties(); while ($regioncounties = mysql_fetch_array ($regioncounties_set)){ echo "<ul>"; if ($regioncounties ['county_region'] == 1); echo "<li>" . $regioncounties ['county_description'] . "</li>"; echo "</ul>"; } } ?> table `county` -- INSERT INTO `county` (`county_id`, `county_description`, `county_region`) VALUES (1, 'Cornwall', 1), (2, 'Devon', 1), (3, 'Somerset', 1), (4, 'Wiltshire', 18), region` ( `region_id` int( NOT NULL AUTO_INCREMENT, `region_description` varchar(40) NOT NULL, PRIMARY KEY (`region_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=19 ; -- -- Dumping data for table `region` -- INSERT INTO `region` (`region_id`, `region_description`) VALUES (1, 'South West'), (2, 'South East'), (4, 'Dorset'), (7, 'East Anglia'), (8, 'Home Counties'), (9, 'London & South East'), I have the id of 1 in at the moment but still am not getting the right output Link to comment https://forums.phpfreaks.com/topic/245014-if-statement-not-working/ Share on other sites More sharing options...
skwap Posted August 17, 2011 Share Posted August 17, 2011 Try this <?php $regions_set = findregion(); while ($regions = mysql_fetch_array ($regions_set)){ echo "<ul>"; echo "<li><a href=\"viewevents.php?url_regionid=" .urlencode ($regions ['region_id']) . "\">" . $regions ['region_description'] . "</a></li>"; $regioncounties_set = findregionscounties(); while ($regioncounties = mysql_fetch_array ($regioncounties_set)){ echo "<ul>"; if($regioncounties ['county_region'] == 1) { echo "<li>" . $regioncounties ['county_description'] . "</li>"; echo "</ul>"; } } } ?> Link to comment https://forums.phpfreaks.com/topic/245014-if-statement-not-working/#findComment-1258521 Share on other sites More sharing options...
barniegilly Posted August 17, 2011 Author Share Posted August 17, 2011 yes that great thank you very much Link to comment https://forums.phpfreaks.com/topic/245014-if-statement-not-working/#findComment-1258528 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.