(newbie post) PHP dropdown list, to insert a value from a dropdown list into database
<p>could someone please help me with this problem, sorry for the Language in the code. Im trying to make it that way, that when someone selects a option and clicks the button that it will be inserted into my database, I already checked out if the name are all correct and such, and they are.</p>

<p>Note: Im not trying to select a value from my database, into my dropdown list, only to insert the value, like a application form for an account.</p>

<p>Note: If someone has asked the same question, it would be Awesome! if you could paste link in the comments, Thanks.</p>

<pre><code>&lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="post"&gt;
&lt;select name="room" value="options"&gt;
&lt;option value="Einstaklings" name="102"&gt;Alment Einstaklings Herbergi&lt;/option&gt;
&lt;option value="Tveggja" name="102"&gt;Alment Tveggja manna Herbergi&lt;/option&gt;
&lt;option value="Business" name="201"&gt;Business Herbergi&lt;/option&gt;
&lt;option value="Fjolskyldu" name="301"&gt;Fjölskyldu Herbergi&lt;/option&gt;
&lt;option value="Svitu" name="401"&gt;Svítu&lt;/option&gt;
&lt;/SELECT&gt;
&lt;input type="submit" value="Senda"/&gt;
&lt;/form&gt;

&lt;?php

$db_tengi=@mysql_connect('localhost', 'root', '');
    if (!$db_tengi) {
        exit('&lt;p&gt;Cant Connect&lt;/p&gt;');
    };

if(!@mysql_select_db('hotel')){
    exit('&lt;p&gt;Cant Connect&lt;/p&gt;');
};



$room = array(
'Einstaklings' =&gt; 101,
'Tveggja' =&gt;102,
'Business' =&gt; 201,
'Fjolskyldu' =&gt;301,
'Svítu' =&gt; 401
 );

function generateSelect($name = '', $options = array()) {
$html = '&lt;select name="'.$name.'"&gt;';
foreach ($options as $option =&gt; $value) {
    $html .= '&lt;option value='.$value.'&gt;'.$option.'&lt;/option&gt;';
}
$html .= '&lt;/select&gt;';
return $html;
 }
 $html = generateSelect('room', $room);


 if (
    $sql = "INSERT INTO `registration` SET 
    room_ID_FK='$room'"
    )
    if(@mysql_query($sql)){
        echo '&lt;p&gt; Insert Complete&lt;/p&gt;';
    }
    else{
        echo '&lt;p&gt; Error Insert failed.' . mysql_error() . '&lt;/p&gt;'; 
    };


  ?&gt;
</code></pre>
