Re: [PHP] array insert help

2003-03-22 Thread Ernest E Vogelsinger
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.
>
>
>
>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:

Home Address:



Work Address:



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



RE: [PHP] array insert help

2003-03-22 Thread Jason Dulberg
Thanks for your help...

I tried the code as you suggested however when I attempted to echo the
variables for testing but nothing showed.

for($i = 0; $i <= 1; ++$i) {
   echo "address".$_POST['address']['address'][$i];
   echo "city".$_POST['address']['city'][$i];
}

The form fields are as you suggested as well.

Thanks again!

Jason

> -Original Message-
> From: Ernest E Vogelsinger [mailto:[EMAIL PROTECTED]
> Sent: March 22, 2003 4:05 PM
> To: Jason Dulberg
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] array insert help
>
>
> 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.
> >
> >
> >
> >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:
>
> Home Address:
> 
> 
>
> Work Address:
> 
> 
>
> 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



RE: [PHP] array insert help

2003-03-22 Thread Ernest E Vogelsinger
At 22:24 22.03.2003, Jason Dulberg said:
[snip]
>Thanks for your help...
>
>I tried the code as you suggested however when I attempted to echo the
>variables for testing but nothing showed.
>
>for($i = 0; $i <= 1; ++$i) {
>   echo "address".$_POST['address']['address'][$i];
>   echo "city".$_POST['address']['city'][$i];
>}
[snip] 

Jason,

I tried the following and it worked:


Home Address:



Work Address:





address $i: ".$_POST['address']['address'][$i];
   echo "city $i: ".$_POST['address']['city'][$i];
}



-- 
   >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