Jump to content

IF STATEMENT NOT WORKING


barniegilly

Recommended Posts

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

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>";
}
		}
	}
?>

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.