Re: Making variables with an iteration? STILL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thomas Munz wrote:
> I think you can use the export() function for that..

He probably means http://php.net/extract but that defeats the purpose of
turning register_globals OFF and is BAD SECURITY.

>> Here's the full code and the driving page:
>>
>> http://rsossam-lap.ces.ncsu.edu/leadership/test.html
>>
>> <snip>
>> <?php
>> for ($i=1; $i<10; $i++)
>> {
>>   if (isset ($_POST['choice'.$i]))
>>   {
>>    for ($j=1; $j<5; $j++)
>>    {
>>     $tempChoice = "choice" . $j;
>>     $$tempChoice = $_POST['choice'.$i];
>>    }
>>   }
>> }

Work out what this does by hand, step by step:
$i $j
1   1   $tempChoice = 'choice1'; $choice1 = $_POST['choice1'];
1   2   $tempChoice = 'choice2'; $choice2 = $_POST['choice1'];
1   3   $tempChoice = 'choice3'; $choice3 = $_POST['choice1'];
1   4   $tempChoice = 'choice4'; $choice4 = $_POST['choice1'];
1   5   $tempChoice = 'choice5'; $choice5 = $_POST['choice1'];
2   1   $tempChoice = 'choice1'; $choice1 = $_POST['choice2'];
2   2   $tempChoice = 'choice2'; $choice2 = $_POST['choice2'];
2   3   $tempChoice = 'choice3'; $choice3 = $_POST['choice2'];
2   4   $tempChoice = 'choice4'; $choice4 = $_POST['choice2'];
2   5   $tempChoice = 'choice5'; $choice5 = $_POST['choice2'];
.
.
.


Is that what you want?

>>    echo $choice1;
>>    echo $choice2;
>>    echo $choice3;
>>    echo $choice4;
>> ?>
>> </snip>
>>
>> The problem seems to be that it is only doing this on the last one, no
>> matter which one it is...  I know it is in the iterations, but I can't
>> place my finger on where I need to change things up.
>>
>> --
>> Robert Sossomon, Business and Technology Application Technician
>> 4-H Youth Development Department
>> 200 Ricks Hall, Campus Box 7606
>> N.C. State University
>> Raleigh NC 27695-7606
>> Phone: 919/515-8474
>> Fax:   919/515-7812
>> robert_sossomon@xxxxxxxx
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux