hi;

please help to check this code. i have a fucntion name to use in my select dropdown list, and I problem in calling the the function name;

here is the whole code of my function.

function getAllR($Region_id) {
		//returns an array with city info
		$query="SELECT * FROM cityinfo where Region_index='$Region_id'";
		$result=mysql_query($query);
		if (!$result)
			return false;
		else {
			$i=0;
			$returnArray=array();
			while ($row=mysql_fetch_array($result)) {
				$returnArray[$i]=new city();
				$returnArray[$i]->City_id=$row['City_id'];
				$returnArray[$i]->Region_index=$row['Region_index'];
				$returnArray[$i]->displayName=$row['City_name'];
				$i++;
			}	
			return $returnArray;	
		}
	}

here the whole code of my dropdown list

$cities=region::getAllR();
					if (!isError($cities)){
						foreach ($cities as $element => $value) {
							echo '<option value="'.$value->City_id.'"';
							if ($value->City_id=='$city')
								echo ' selected="selected"';
							echo '>'.$value->displayName.'</option>';
						}
					}
				}

what is wrong in this code? why it does not display the item for the dropsown list?

please i need your help, thanks advance

Recommended Answers

All 2 Replies

Just taking a quick look, you have not passed in a parameter to the region::getAllR() call. Note that the signature of the function is function getAllR($Region_id) which contains a single parameter with no default value set. Therefore you must call the function like so: region::getAllR($aRegionId);

Just taking a quick look, you have not passed in a parameter to the region::getAllR() call. Note that the signature of the function is function getAllR($Region_id) which contains a single parameter with no default value set. Therefore you must call the function like so: region::getAllR($aRegionId);

thanks, I am going to try it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.