At 20:59 22.03.2003, Jason Dulberg said:
--------------------[snip]--------------------
>My problem is that I'm not sure how to set up the array for the fields and
>how to take the input fields and insert them. Do I need a multidimensional
>array for this?
>
>ie.
><input type="text" name="address[address][]">
><input type="text" name="address[city][]">
>
>How would I decode that to create an insert statement??
--------------------[snip]-------------------- 

I believe your example would work. However since you have a definite number
of adresses you could add the index directly, as here:

<b>Home Address:</b><br />
<input type="text" name="address[address][0]">
<input type="text" name="address[city][0]">

<b>Work Address:</b><br />
<input type="text" name="address[address][1]">
<input type="text" name="address[city][1]">

When the form is received you will have an array for adress that looks like
this:

$_REQUEST['address'] = array(
    'address' => array(0 => 'home address', 1 => 'work address'),
    'city' => array(0 => 'home city', 1 => 'work city'));

To insert the home address you'd create an SQL statement like this:

for($i = 0; $i <= $number_of_addresses; ++$i) {
    $sql = "insert into address(adress, city) values (" .
        "{$_REQUEST['address']['address'][$i]}," .
        "{$_REQUEST['address']['city'][$i]})";
    // more code
}

Hope this helps,

-- 
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to