So, I have a table called "Countries", and it looks like this:
---------------------------
|Country | Code |
---------------------------
|Afganastan | AF |
|ÅLAND ISLANDS| AX |
| etc. | etc. |
---------------------------
What I want to do is create a dynamic menu in which the user selects the country and is stored as a value that I can call after the user gets to submit.
I tried something here, but I'm not sure what it does, because I'm still new to PHP and HTML to the extent that I just enter things to see what happens.
In any case, I was really stuck, and I tried to use google and the search function on this site, and nothing I found worked for me ...
The code I tried is as follows:
<select>
<?php
$result = mysql_query('SELECT Country FROM Countries');
echo '<select name="country">';
while ($row = mysql_fetch_array($result))
{
echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
}
echo '</select>';
?>
</select>
. :
.$row['name']
, , . , , .
:
<select name = 'country'>
<?php
include ("account.php");
include ("connect.php");
$result = mysql_query('SELECT Code , Country FROM Countries');
while ($row = mysql_fetch_array($result))
{?>
<option value="<?php echo $row['Code']?>"><?php echo $row['Country']?></option>
<?php}
?>
</select>
include ("account.php"); include ("connect.php"); .