returning values
Posted: Mon Jan 08, 2007 6:58 am
feyd | Please use
And i am trying to populate drop down list using foreach statement.
The above code works fine if there are more than 1 row. it does not work if there is only one row.
Thanx
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello,
I have written a function to fetch data and return values.Code: Select all
function fetchAllData($cond,$table)
{
//echo "SELECT * FROM $table";
$query=mysql_query("SELECT * FROM $table $cond");
while($data=mysql_fetch_array($query))
{
$datas[]=$data;
}
return $datas;
}
$membrsData=fetchAllData("","members");Code: Select all
foreach($membrsData as $membrsDatas)
{
if($membrsDatas['Country']==$country['countryName'])
$countrys.="<option selected>$membrsDatas[Country]</option>";
else
$countrys.="<option>$membrsDatas[Country]</option>";
}The above code works fine if there are more than 1 row. it does not work if there is only one row.
Thanx
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]