Jump to content

Multiple Form Textbox Problem


samsina

Recommended Posts

I have problem. So at work I am making this gigantic form, everything done except this part.

 

here is the database view:

 

      name, phone    , type

ex:  sam , 12345678, installation

ex:  jim  ,  12222222, support

 

html view (fixed size of three for each):

 

install

name:_____  phone:______

name:_____  phone:______

name:_____  phone:______

 

support

name:_____  phone:______

name:_____  phone:______

name:_____  phone:______

 

submit

 

so basically the form includes from contact lists

1)installation group

2)support group

 

into one database. the easier way to name each field as a unique text boxes and process them one at a time... any efficient way?

Link to comment
Share on other sites

try something like this

 

<?php
if (isset($_GET['sub']))
{
    foreach ($_GET['name'] as $type=>$names)
    {
        foreach ($names as $k => $name) {
            $phone =  $_GET['phone'][$type][$k];
            
            $sql = "INSERT INTO mytable (name, phone,type)
                    VALUES ('$name', '$phone', $type')";
                    
            echo "<pre>$sql</pre>";   // update here
        }
    }
}

?> 
<form>
<h3>Installation</h3>
<?php
for ($i=0; $i<3; $i++)
{
echo <<<TXT
Name <input type="text" name="name[installation][$i]">
Phone <input type="text" name="phone[installation][$i]"> <br />
TXT;
}
?>
<h3>Support</h3>
<?php
for ($i=0; $i<3; $i++)
{
echo <<<TXT
Name <input type="text" name="name[support][$i]">
Phone <input type="text" name="phone[support][$i]"> <br />
TXT;
}
?>
<input type="submit" name="sub" value="Submit">
<form> 

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.