Hi:
PHP, mySQL newbie here!
I've got a table in mySQL with two fields; CountryID, CountryName
I'd like to populate a selection box dynamically using PHP. I know how to this easily in Cold Fusion/ ASP , but I'm new to the PHP syntax.
Please help!!!!
Thanx in advance. Kamy
One way is to do something like .....
echo "<select name=country>";
$result = mysql_query("SELECT * FROM tbl");
while ($row = mysql_fetch_array($result)) { echo "<option value=\"{$row['CountryId']}\">$row['CountryName']</option>" }
echo "</select>"
//Get result into right format while ($row = mysql_fetch_array($result)) { $resource = stripslashes($row["resource"]); $option_block .= "<option value = \"$resource\">$resource</option>"; }
//to use in form <select name="resource"> <? echo "$option_block";?> </select>
Did that, but I get the following error mesage:
Parse error: parse error, expecting T_STRING' orT_VARIABLE' or `T_NUM_STRING' in
T_STRING' or
Or maybe something like:
$query = "select * from tbl"; $result = @($query); foreach($result as $row) { echo "<option value='".$row["CountryID"]."'>".$row["CountryName"]."</option>"; } echo "</select>";