Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7885843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:10:26+00:00 2026-06-03T05:10:26+00:00

could someone please help me with this problem, sorry for the Language in the

  • 0

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.

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.

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

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

<?php

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

if(!@mysql_select_db('hotel')){
    exit('<p>Cant Connect</p>');
};



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

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


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


  ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:10:27+00:00Added an answer on June 3, 2026 at 5:10 am

    1) In your select don’t give names to each option

    <select name="room" value="options">
    <option value="Einstaklings">Alment Einstaklings Herbergi</option>
    <option value="Tveggja">Alment Tveggja manna Herbergi</option>
    <option value="Business">Business Herbergi</option>
    <option value="Fjolskyldu">Fjölskyldu Herbergi</option>
    <option value="Svitu">Svítu</option>
    </SELECT>
    

    2) You need to recieve your posted data, it will be in superglobal array $_POST

    <?php 
       $room = $_POST['room'];
    ?>
    

    3) You need to write this data to Data Base, after you made connection to it

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please could someone help diagnose this tiny problem that shouldn't be one - trying
Could someone please help solve this problem?
Could someone please help explain why I can't get this to work? I properly
I've recently written this with help from SO. Now could someone please tell me
Could someone please help me with the code for below requirement or scenarios...I achieved
I was wondering if someone could help me understand this problem. I prepared a
I hope someone can help with this please. I am trying to query an
Could someone please help me with synchronizing varied number of threads? The problem is
Could someone please help me with the following problem: There are two classes MainForm
Could someone please help me out with the following problem in java. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.