Re: [PHP] Getting arrays out of HTTP_POST_VARS

2001-10-27 Thread Ian Evans

Wow, that holds the land speed record for a reply. Thanks for your help!

Mike Eheler wrote:

> $HTTP_POST_VARS['middlecasts']['key']['subkey']['wecould']['go_on']['forver']; 


-- 
Ian Evans
Digital Hit Entertainment - News and Information
http://www.digitalhit.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Getting arrays out of HTTP_POST_VARS

2001-10-27 Thread Mike Eheler

Onething I should note.. this doesn't work within a string.

For example:

let's say:
$HTTP_POST_VARS['key']['subkey'] = 'Hello World!';
$HTTP_POST_VARS['key2'] = 'World #2!';

if we do:

echo "key2: $HTTP_POST_VARS[key2]";

The output will be:

key2: World #2!

However, if we do:

echo "key1/subkey: $HTTP_POST_VARS[key1][subkey]";

The output should be:

key1/subkey: Array[subkey]

So what you want to do is:

echo 'key1/subkey: ' . $HTTP_POST_VARS['key1']['subkey'];

Which will get you the desired output of:

key1/subkey: Hello World!

Mike



Mike Eheler wrote:

> $HTTP_POST_VARS['middlecasts']['key']['subkey']['wecould']['go_on']['forver']; 
>
>
> ;)
>
> Mike
>
>
>
> Ian Evans wrote:
>
>> My mind is going blank here and I feel like I'm missing something basic.
>>
>> I have an insert form for movie profiles that takes cast members, 
>> writers and directors and inserts them into the tables for the 
>> correct movieid.
>>
>> In the old version of the script I would repeat the inserting section 
>> of the code three times, once for casts, once for directors and once 
>> for writers. The script checks if the person's first/middle/last name 
>> exists in the
>> people table. If it does it grabs the id number, if it doesn't it 
>> doesn't it inserts it and gets the id number.
>> The peopleid and titleid are then inserted into the appropriate 
>> table. (casts, writers, directors)
>>
>> I decided to streamline the code with a function so that calling 
>> peopleinserter($table,$titleid) would loop
>> through the form variables and insert into the appropriate table. I 
>> can easily grab the results of the $HTTP_POST_VARS but I'm going 
>> blank trying to get the array out of the array.
>>
>> Here's a snippet:
>> function peopleinserter ($table,$titleid) {
>> //$titleid = the titleid from the titles table
>> //$table = the job table e.g. casts, directors, writers
>> global $HTTP_POST_VARS;
>> $firstvar = "first$table"; //if $table = casts it would grab the 
>> firstcasts variables from the form
>> $middlevar = "middle$table";
>> $lastvar = "last$table";
>> while (list ($key, $val) = each ($HTTP_POST_VARS[$lastvar])) {
>> //in this example $lastvar=lastcasts, so it's calling each 
>> ($HTTP_POST_VARS[lastcasts])
>> // if I echo $key $val for this I would get for example "0 Thornton 1 
>> Jolie
>> //end snippet
>>
>> How do I call the key of the firstcasts, middlecasts, lastcasts 
>> arrays so I can do stuff like:
>> $lastcasts[$key] = trim($lastcasts[$key]); and
>> $sql = "SELECT peopleid, first, middle, last FROM people WHERE 
>> first='$firstcasts[$key]' and middle='$middlecasts[$key]' AND 
>> last='$lastcasts[$key]]'";
>>
>> In other words, how do I get those three arrays out of the 
>> HTTP_POST_VARS array?
>>
>> Banging head on desk...
>>
>>
>
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Getting arrays out of HTTP_POST_VARS

2001-10-27 Thread Mike Eheler

$HTTP_POST_VARS['middlecasts']['key']['subkey']['wecould']['go_on']['forver'];

;)

Mike



Ian Evans wrote:

>My mind is going blank here and I feel like I'm missing something basic.
>
>I have an insert form for movie profiles that takes cast members, writers and 
>directors and inserts them into the 
>tables for the correct movieid.
>
>In the old version of the script I would repeat the inserting section of the code 
>three times, once for casts, 
>once for directors and once for writers. The script checks if the person's 
>first/middle/last name exists in the
>people table. If it does it grabs the id number, if it doesn't it doesn't it inserts 
>it and gets the id number.
>The peopleid and titleid are then inserted into the appropriate table. (casts, 
>writers, directors)
>
>I decided to streamline the code with a function so that calling 
>peopleinserter($table,$titleid) would loop
>through the form variables and insert into the appropriate table. I can easily grab 
>the results of the 
>$HTTP_POST_VARS but I'm going blank trying to get the array out of the array.
>
>Here's a snippet:
>function peopleinserter ($table,$titleid) {
>//$titleid = the titleid from the titles table
>//$table = the job table e.g. casts, directors, writers
>global $HTTP_POST_VARS;
>$firstvar = "first$table"; //if $table = casts it would grab the firstcasts variables 
>from the form
>$middlevar = "middle$table";
>$lastvar = "last$table";
>while (list ($key, $val) = each ($HTTP_POST_VARS[$lastvar])) {
>//in this example $lastvar=lastcasts, so it's calling each 
>($HTTP_POST_VARS[lastcasts])
>// if I echo $key $val for this I would get for example "0 Thornton 1 Jolie
>//end snippet
>
>How do I call the key of the firstcasts, middlecasts, lastcasts arrays so I can do 
>stuff like:
>$lastcasts[$key] = trim($lastcasts[$key]); and
>$sql = "SELECT peopleid, first, middle, last FROM people WHERE 
>first='$firstcasts[$key]' and middle='$middlecasts[$key]' AND 
>last='$lastcasts[$key]]'";
>
>In other words, how do I get those three arrays out of the HTTP_POST_VARS array?
>
>Banging head on desk...
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]