-
PHP (
http://www.daniweb.com/forums/forum17.html)
| god_1896 | Sep 8th, 2008 5:01 am | |
| calling function name? i need help Quote: 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>';
}
}
} Quote: what is wrong in this code? why it does not display the item for the dropsown list?
please i need your help, thanks advance | |
| darkagn | Sep 8th, 2008 5:58 am | |
| Re: calling function name? i need help 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); |
| god_1896 | Sep 8th, 2008 6:07 am | |
| Re: calling function name? i need help Quote: Originally Posted by darkagn (Post 686565) 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 |
| All times are GMT -4. The time now is 9:56 pm. | |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC