Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.