Hi,
i have a code like this
[CODE]print <<< EOF
<select>
$countries
</select>
EOF;
I want that $countries calls and executes the following function:
[code=php]function do_countries() {
$query = “SELECT * from ip_country group by country” ;
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
{
echo ‘<option value=”‘ . $row[‘country’] . ‘”>’ . $row[‘country’] . ‘</option>’;
} }
That is the original function but i had to change the ECHO to RETURN like this to it wont executes the code when trying to declare the variable:
[code=php]function do_countries() {
$query = “SELECT * from ip_country group by country” ;
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
{
return ‘<option value=”‘ . $row[‘country’] . ‘”>’ . $row[‘country’] . ‘</option>’;
} }
and finally:
[CODE]
$countries = do_countries();
print <<< EOF
<select>
$countries
</select>
EOF;
it wont work quite well because its supposed to generate a full list of countries and i only get the first one of the list. I guess it has to do with changing the ECHO for the RETURN but if i dont change it then it wont work either. Can you please help me out?
Thank you.