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 3279504
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:36:01+00:00 2026-05-17T19:36:01+00:00

Can any one please help me? I am new to php, currently I am

  • 0

Can any one please help me? I am new to php, currently I am trying to use $_POST['item'] to obtain a string (consists of many words) from a dropdown box and then process it. However, when I use $_POST['item'], only first word is returned, the rest of words are missing.

I have a dropdown box, something like:

echo "<form action='process_form.php' method='post'>";
echo "Select an item<br />";
echo "<select name='item' id='item'>";
...
...
...

each item in the dropdown box is a string that has product names like:

dressmaker mannequin size 12
torso mannequin in white color
...

User will then select an item from the dropdown box. When I used $_POST['item'] to obtain this string, I get the first word “dressmaker”, all the rests were missing.

How do I get the whole string?

Many thanks in advance.

  • 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-05-17T19:36:01+00:00Added an answer on May 17, 2026 at 7:36 pm

    I am not sure exactly what you are doing but I would do something like this. For this example I assume that the values “dressmaker mannequin size 12” will correspond to the values of the columns in the database to which I will refer to as “colA, colB, colC, and colD”, and in addition I assume you have an “ID” column in your database.

    Here is the code I would use to generate the select drop-down list:

    //$query is the variable storing the result of the mysql_query();
    //assumption is that the result-set is non-empty
    
    echo '<select name="item" id="item">\n'; //\n - new line character
    
    //run through the loop to generate the items inside the list
    while ($result = mysql_fetch_assoc($query)) {
        //note the id - it will be used to find data in the
        //database after the POST is complete
    
        //couple of temp variables (not necessary but makes code cleaner)
        $database_id = $result["ID"];
        $colA = $result["colA"]; //ex:dressmaker
        $colB = $result["colB"]; //ex:mannequin
        $colC = $result["colC"]; //ex:size
        $colD = $result["colD"]; //ex:12
    
        //add option to the select drop-down
        echo "<option value=\"$database_id\">$colA $colB $colC $colD</option>\n";
    }
    echo "</select>";
    

    Now to retrieve the data from the POST. I am including the code Drewdin suggested.

    //form was submitted already
    //assumption is that the database connection is established
    $item_id = mysql_real_escape_string(trim($_POST["item"]));
    
    //Now get the info from the database for this id
    //table is "table"
    $string = "SELECT * FROM table WHERE ID = $item_id";
    $query = mysql_query($string) or die("Could not complete the query: $string");
    
    //assumption here is that the result set is non-empty
    $result = mysql_fetch_assoc($query);
    
    $colA = $result["colA"]; //ex:dressmaker
    $colB = $result["colB"]; //ex:mannequin
    $colC = $result["colC"]; //ex:size
    $colD = $result["colD"]; //ex:12
    
    //now you can use the values of colA-D to compute whatever you want
    

    Hope this helps. Using database ids is nice for security plus it makes things more manageable.

    Regarding using this blog. You can post comments to the answers people post. If you want however to add something to your question, you can edit your original question and just make sure its obvious what was added.

    When the issue is resolved and if any answer helped and you liked it, you can pick it as the final answer by clicking the check mark next to it.

    Best of luck

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

Sidebar

Related Questions

hii everyone am sowmya am brand new to android please can any one help
Can any one please help me solve this. I am resizing some flash object/embed
Can anyone please help me how to convert string to date I have 3
Can some one please help explain why when I block and continue observer's onNext
I am facing a problem to call https from Android. Can any one please
Can anyone please help me to work out how to achieve the following? I
Can anyone please help me to add video controls (play, pause, forward, seekbar) to
Can anyone please help me with this...I'm not very good with regular expressions and
Can anyone please help me to understand how should i access json data in
Can anyone please help. I'm following a tutorial found here as I have a

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.