Having trouble with php....input type=hidden

Having trouble with php....input type=hidden

am 17.10.2007 00:39:21 von DBA

Without giving a lot of script at this time, I am having a problem with
php and form input type="hidden". Problem is that the hidden variable
displays last line from database query.

Some code.
if ($field_name=="member_lname") {
echo " " .
$result['member_lname'] . ', ' . $result['member_fname'] . "
";
echo "" . $result['member_id'] . " />" ; }

produces this from form:
Back, Joe 0026
Clan, Bill 0025
Dant, Norbert 0020
Cleene, Nor 0013
De Wa, Frank 0012
Erick, B.C. 0006
Evans, Mary 0027
Far, Steve 0005

after selection from form $_POST produces
correct name "Dant, Norbert" but grabs last number "0005" and not "0020".

Any help would be appreciated.

Re: Having trouble with php....input type=hidden

am 17.10.2007 03:08:46 von Jerry Stuckle

dba wrote:
> Without giving a lot of script at this time, I am having a problem with
> php and form input type="hidden". Problem is that the hidden variable
> displays last line from database query.
>
> Some code.
> if ($field_name=="member_lname") {
> echo " " .
> $result['member_lname'] . ', ' . $result['member_fname'] . "
";
> echo "" . $result['member_id'] . " />" ; }
>
> produces this from form:
> Back, Joe 0026
> Clan, Bill 0025
> Dant, Norbert 0020
> Cleene, Nor 0013
> De Wa, Frank 0012
> Erick, B.C. 0006
> Evans, Mary 0027
> Far, Steve 0005
>
> after selection from form $_POST produces
> correct name "Dant, Norbert" but grabs last number "0005" and not "0020".
>
> Any help would be appreciated.
>

To get multiple values returned, you need to use an array, i.e.

echo '';

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Having trouble with php....input type=hidden

am 17.10.2007 04:00:09 von DBA

Thank you. I will give that a try.


Jerry Stuckle wrote:
> dba wrote:
>
>> Without giving a lot of script at this time, I am having a problem
>> with php and form input type="hidden". Problem is that the hidden
>> variable displays last line from database query.
>>
>> Some code.
>> if ($field_name=="member_lname") {
>> echo " " .
>> $result['member_lname'] . ', ' . $result['member_fname'] . "
";
>> echo "" . $result['member_id'] . " />" ; }
>>
>> produces this from form:
>> Back, Joe 0026
>> Clan, Bill 0025
>> Dant, Norbert 0020
>> Cleene, Nor 0013
>> De Wa, Frank 0012
>> Erick, B.C. 0006
>> Evans, Mary 0027
>> Far, Steve 0005
>>
>> after selection from form $_POST produces
>> correct name "Dant, Norbert" but grabs last number "0005" and not "0020".
>>
>> Any help would be appreciated.
>>
>
> To get multiple values returned, you need to use an array, i.e.
>
> echo '';
>

Re: Having trouble with php....input type=hidden

am 17.10.2007 15:20:01 von DBA

Think you only use an array when you want multiple values put into one
variable/array. As you can see from the included code I am using two
separate variables. One variable is 'selection' for 'member_lname' and
the other is 'member_id' for 'member_id'.

If I wanted both put into a variable, then I would use an array.

Right?


dba wrote:
> Thank you. I will give that a try.
>
>
> Jerry Stuckle wrote:
>
>> dba wrote:
>>
>>> Without giving a lot of script at this time, I am having a problem
>>> with php and form input type="hidden". Problem is that the hidden
>>> variable displays last line from database query.
>>>
>>> Some code.
>>> if ($field_name=="member_lname") {
>>> echo " " .
>>> $result['member_lname'] . ', ' . $result['member_fname'] . "
";
>>> echo "" . $result['member_id'] . " />" ; }
>>>
>>> produces this from form:
>>> Back, Joe 0026
>>> Clan, Bill 0025
>>> Dant, Norbert 0020
>>> Cleene, Nor 0013
>>> De Wa, Frank 0012
>>> Erick, B.C. 0006
>>> Evans, Mary 0027
>>> Far, Steve 0005
>>>
>>> after selection from form $_POST produces
>>> correct name "Dant, Norbert" but grabs last number "0005" and not
>>> "0020".
>>>
>>> Any help would be appreciated.
>>>
>>
>> To get multiple values returned, you need to use an array, i.e.
>>
>> echo '';
>>

Re: Having trouble with php....input type=hidden

am 17.10.2007 17:38:03 von Jerry Stuckle

dba wrote:
> Think you only use an array when you want multiple values put into one
> variable/array. As you can see from the included code I am using two
> separate variables. One variable is 'selection' for 'member_lname' and
> the other is 'member_id' for 'member_id'.
>
> If I wanted both put into a variable, then I would use an array.
>
> Right?
>
>
> dba wrote:
>> Thank you. I will give that a try.
>>
>>
>> Jerry Stuckle wrote:
>>
>>> dba wrote:
>>>
>>>> Without giving a lot of script at this time, I am having a problem
>>>> with php and form input type="hidden". Problem is that the hidden
>>>> variable displays last line from database query.
>>>>
>>>> Some code.
>>>> if ($field_name=="member_lname") {
>>>> echo " " .
>>>> $result['member_lname'] . ', ' . $result['member_fname'] . "
";
>>>> echo "" . $result['member_id'] . " />" ; }
>>>>
>>>> produces this from form:
>>>> Back, Joe 0026
>>>> Clan, Bill 0025
>>>> Dant, Norbert 0020
>>>> Cleene, Nor 0013
>>>> De Wa, Frank 0012
>>>> Erick, B.C. 0006
>>>> Evans, Mary 0027
>>>> Far, Steve 0005
>>>>
>>>> after selection from form $_POST produces
>>>> correct name "Dant, Norbert" but grabs last number "0005" and not
>>>> "0020".
>>>>
>>>> Any help would be appreciated.
>>>>
>>>
>>> To get multiple values returned, you need to use an array, i.e.
>>>
>>> echo '';
>>>
>

If you don't want to use an array, then you can't place multiple values
in the same field name.

It works or radio buttons because the group together only sends one
value. But hidden fields send one value for each field in the form.
And if you don't use an array, PHP will just overlay each previous value
with the next one of the same name. The result is you get only the last
field.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Having trouble with php....input type=hidden

am 17.10.2007 17:42:21 von me

It wont work the way you are trying to do it. You would need to have both
values in the the select or radio value. Then explode it or something.
There is no way to link the hidden field to the correct value of the select
in your code.

if ($field_name=="member_lname") {
echo " value='{$result['member_lname']},{$result['member_fname']}:{ $result['member_id']}'>
{$result['member_lname']},{$result['member_fname']}
";
}

$value = explode(":",$_REQUEST['selection']);

$name = $value[0];
$id = $value[1];

There are many ways to do this this is just a quick example. Also If you use
this code be sure to scrub the $_REQUEST var

Eric Haskins
PHP Programmer
Parked.com