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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:31:31+00:00 2026-05-13T07:31:31+00:00

<input name=names[] type=text/><select><option value=male>male</option><option value=female>female</option></select> <input name=names[] type=text/><select><option value=male>male</option><option value=female>female</option></select> <input name=names[] type=text/><select><option value=male>male</option><option

  • 0
<input name="names[]" type="text"/><select><option value="male">male</option><option value="female">female</option></select>  
<input name="names[]" type="text"/><select><option value="male">male</option><option value="female">female</option></select>  
<input name="names[]" type="text"/><select><option value="male">male</option><option value="female">female</option></select>  





    if (!empty($_POST['names'])) {
    foreach ($_POST['names'] AS $names) {
        // add to the database
        if (!empty($names)){
            $rs=mysql_query("SELECT names FROM table WHERE names = '$names' LIMIT 1");
            if(mysql_num_rows($rs) == 0) {
        mysql_query("INSERT INTO table (names,gender) VALUES ('$names','$gender')");
            }
        }
    }
}

This does inset the names however i don’t know how i can make the genders work for each individual name.

  • 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-13T07:31:31+00:00Added an answer on May 13, 2026 at 7:31 am

    You need to give your SELECT elements a name:

    <input name="names[]" type="text"/><select name="genders[]"><option value="male">male</option><option value="female">female</option></select>
    

    Now you can use the key of $_POST['names'] to get the corresponding gender:

    foreach ($_POST['names'] AS $key => $names) {
        // add to the database
        if (trim($names) != '' && !empty($_POST['genders'][$key]) && in_array($_POST['genders'][$key], array('male', 'female'))) {
            $gender = $_POST['genders'][$key];
            $rs = mysql_query("SELECT names FROM table WHERE names = '".mysql_real_escape_string($names).' LIMIT 1");
            if (mysql_num_rows($rs) == 0) {
                mysql_query("INSERT INTO table (names,gender) VALUES ('".mysql_real_escape_string($names)."','$gender')");
            }
        }
    }
    

    You should also use mysql_real_escape_string to sanatize the data sent by the user.

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

Sidebar

Related Questions

Background Users type information into web form inputs such as: <input type=text name=report_name value=First
Here's an example of what I mean: I have an array: array('type'=>'text', 'class'=>'input', 'name'=>'username',
I have a form with two text_fields: <input type=text id=post_name name=post[name] /> <input type=text
I have an input box like the following: <input type=text value= somethingSpecial=filename.txt id=myID class=box>
This is where i put a popup box into echo <tr><td>.$set['Name'].</td><td>.$set['Position'].</td><td><select name='aaa'><option value='default'>Not Share</option><option
How to get the type of input in the form by its name? for
i want to check users' input value when he input his name, if his
So I have the following html: <div id=divForComponents> <input type=button value=+ onclick=addFilter('divForComponents')/> </div> And
jQuery('ol.productList li.product input[name*=cart.pAsin.]').load().each(function(){ // each function var asinId = jQuery(this).val(); var pUrl = jQuery(this).siblings(a).attr('href');
<?php echo $form->create(); ?> <?php echo $form->hidden('id'); ?> <?php echo $form->input('name')); ?> <?php echo

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.