Jump to content

Insert 2 Values From Drop Down Menu?


justlukeyou

Recommended Posts

Hi,

 

Does anyone know if it is possible to submit 2 values to a database from a drop down menu?

 

I have "Reception Room" being submitted to 'category' but is it possible to submit "Reception-Room" to a column called 'linkcategory'.

 

Or when Reception Room is submitted can I use some form of code to add 'Reception-Room' to another code?

 

 

<option value="Reception Room" >Reception Room</option>

<option value="Hotel" >Hotel</option>

<option value="Night Club" >Night Club</option>

Link to comment
Share on other sites

  • Replies 67
  • Created
  • Last Reply

Top Posters In This Topic

So. .

 

if ($_POST['Submit']){

$category = $_POST['selectname'];

 

{

 

mysql_query("INSERT INTO category (`category`)

VALUES ("'$category'')") or die (mysql_error());

 

mysql_query("INSERT INTO linkcategory (`category`)

VALUES ("'$category'')") or die (mysql_error());

Link to comment
Share on other sites

Hi,

 

Is it possible to add "reception-room" into linkcategory so linkcategory now has a hyphen.  Would I add a string replace to linkcategory so it adds a hyphen.

 

However, I am inserting the "reception room" from a drop down so can I have to two values in the drop down.  "reception room" and "reception-room".

 

mysql_query("INSERT INTO category (`category`)
VALUES ("'$category'')") or die (mysql_error());

mysql_query("INSERT INTO linkcategory (`linkcategory`)
VALUES ("'$linkcategory'')") or die (mysql_error());

Link to comment
Share on other sites

  • 2 weeks later...

Im having a hell of a time with this.

 

I am trying to add the category (reception room) into a column called category but also add reception-room into a column called linkcategory.

 

Firstly I am struggling to add 'reception room' into both category and linkcategory column.

 

Secondly I dont know where to add the stringreplace once I am entering reception room into both columns.

 

Does anyone have any suggestions please?

 

if(isset($_POST['form_id'])){
    $category = mysql_real_escape_string(trim($_POST['category']));
    $firstname = mysql_real_escape_string(trim($_POST['firstname']));
    $surname = mysql_real_escape_string(trim($_POST['surname']));
    $email = mysql_real_escape_string(trim($_POST['email']));
    $website = mysql_real_escape_string(trim($_POST['website']));
    $company = mysql_real_escape_string(trim($_POST['company']));
    $building = mysql_real_escape_string(trim($_POST['building']));
    $streetname = mysql_real_escape_string(trim($_POST['streetname']));
    $state = mysql_real_escape_string(trim($_POST['state']));
    $postcode = mysql_real_escape_string(trim($_POST['postcode']));
    $country = mysql_real_escape_string(trim($_POST['country']));
    $aboutcompany = mysql_real_escape_string(trim($_POST['aboutcompany']));
    $error = false;
    
       if(!isset($category) || empty($category)) {
  $error = "Please select a category.";
    }

    if(!isset($firstname) || empty($firstname)) {
  $error = "Please enter a First Name.";
    }

    if(!isset($surname) || empty($surname)) {
  $error = "Please enter a Surname.";
    }

    if(!isset($email) || empty($email)) {
  $error = "Please enter an email.";
    }

    if(!isset($website) || empty($website)) {
  $error = "Please enter a Website Domain.";
    }

    if(!isset($company) || empty($company)) {
  $error = "Please enter a Company Name.";
    }

    if(!isset($building) || empty($building)) {
  $error = "Please enter a Building Name or Number.";
    }

    if(!isset($streetname) || empty($streetname)) {
  $error = "Please enter a Street Name.";
    }

    if(!isset($state) || empty($state)) {
  $error = "Please enter a State.";
    }

    if(!isset($postcode) || empty($postcode)) {
  $error = "Please enter a Zip Code/Post Code.";
    }

      if(!isset($country) || empty($country)) {
  $error = "Please select your country.";
    }

    if(!isset($aboutcompany) || empty($aboutcompany)) {
  $error = "Please enter details about your company.";
    }




    if(!$error) {

        $query = mysql_query("INSERT INTO organiserdbase (category, category, firstname, surname, email, website, company, building, streetname, state, postcode, country, aboutcompany) VALUES ('".$category."', '".$linkcategory."', '".$firstname."', '".$surname."', '".$email."', '".$website."', '".$company."', '".$building."', '".$streetname."', '".$state."', '".$postcode."', '".$country."', '".$aboutcompany."')");
        if($query) {
        } else {
$error = "There was a problem with the submission. Please try again.";
        }
    }
}

Link to comment
Share on other sites

I have a drop down of around 50 values without the hyphen.

 

If I can enter the value with a hyphen it will save a huge amount of time in building the site.  Thats my plan anyway.

 

 

</div>
	<div id="forminputright">
<select  class="element select medium" id="category" name="category"> 			
			</div> 	
<option value="" selected="selected">Your Job Role:</option>
<option value="Event Manager" >Event Manager</option>
<option value="Event Managent Courses" >Event Managent Courses</option>
<option value="Event Management Software" >Event Management Software</option>
<option value="Entertainment Staff" >Entertainment Staff</option>

Link to comment
Share on other sites

Hi,

 

Yes I manually wrote each entry for the drop down menu.

 

The thing is I would find it much easier for the rest of the site if I can have to columns, one with and one without the hyphen.

 

Once I can enter in both "reception room" and "reception-room" the rest should be quite simple.

Link to comment
Share on other sites

Hi,

 

I had a go at this however I am stuck as to how to add two values into the dropdown area.

 

I'm using the fields 'category' and 'linkcategory'.

 

<select  class="element select medium" id="category, linkcategory" id="category, linkcategory"> 	
<option value="Reception Room" >Reception Room</option>

 

I have tried a few variations but cant get it to work.

 

 

Link to comment
Share on other sites

I'm trying my best to get to work, thats all I can do.

 

This is all my code, Im almost there with it (hopefully)

 

<?php

if(isset($_POST['form_id'])){
    $category = mysql_real_escape_string(trim($_POST['category']));
    $linkcategory = mysql_real_escape_string(trim($_POST['linkcategory']));
    $firstname = mysql_real_escape_string(trim($_POST['firstname']));
    $surname = mysql_real_escape_string(trim($_POST['surname']));
    $email = mysql_real_escape_string(trim($_POST['email']));
    $website = mysql_real_escape_string(trim($_POST['website']));
    $company = mysql_real_escape_string(trim($_POST['company']));
    $building = mysql_real_escape_string(trim($_POST['building']));
    $streetname = mysql_real_escape_string(trim($_POST['streetname']));
    $state = mysql_real_escape_string(trim($_POST['state']));
    $postcode = mysql_real_escape_string(trim($_POST['postcode']));
    $country = mysql_real_escape_string(trim($_POST['country']));
    $aboutcompany = mysql_real_escape_string(trim($_POST['aboutcompany']));
    $error = false;
    
       if(!isset($category) || empty($category)) {
  $error = "Please select a category.";
    }

    if(!isset($firstname) || empty($firstname)) {
  $error = "Please enter a First Name.";
    }

    if(!isset($surname) || empty($surname)) {
  $error = "Please enter a Surname.";
    }

    if(!isset($email) || empty($email)) {
  $error = "Please enter an email.";
    }

    if(!isset($website) || empty($website)) {
  $error = "Please enter a Website Domain.";
    }

    if(!isset($company) || empty($company)) {
  $error = "Please enter a Company Name.";
    }

    if(!isset($building) || empty($building)) {
  $error = "Please enter a Building Name or Number.";
    }

    if(!isset($streetname) || empty($streetname)) {
  $error = "Please enter a Street Name.";
    }

    if(!isset($state) || empty($state)) {
  $error = "Please enter a State.";
    }

    if(!isset($postcode) || empty($postcode)) {
  $error = "Please enter a Zip Code/Post Code.";
    }

      if(!isset($country) || empty($country)) {
  $error = "Please select your country.";
    }

    if(!isset($aboutcompany) || empty($aboutcompany)) {
  $error = "Please enter details about your company.";
    }




    if(!$error) {

        $query = mysql_query("INSERT INTO organiserdbase (category, linkcategory, firstname, surname, email, website, company, building, streetname, state, postcode, country, aboutcompany) VALUES ('".$category."', '".$linkcategory."', '".$firstname."', '".$surname."', '".$email."', '".$website."', '".$company."', '".$building."', '".$streetname."', '".$state."', '".$postcode."', '".$country."', '".$aboutcompany."')");
        if($query) {
        } else {
$error = "There was a problem with the submission. Please try again.";
        }
    }
}

?>



<div id="registerpagecell">
<div id="registerpageheaderorganiser">
Create Your Organiser Profile 
</div>
<div id="registerform">

<form id="form_id"  class="appnitro"  method="post" action="">

    
<?php if($error) echo "<span style=\"color:#ff0000;\">".$error."</span><br /><br />"; ?>		
<ul >


	<div id="forminputcell">
<li id="li_1" >
	<div id="forminputleft">
<label class="description" for="element_3">Your Job Role:</label>
</div>
	<div id="forminputright">
<select  class="element select medium" id="category, linkcategory" > 			
			</div> 	
<option value="" selected="selected">Venue:</option>

<option VALUES('Reception Room', 'reception-room') >Reception Room</option>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.