You are here: Re: problem with php + form + input type = "hidden" « PHP Programming Language « IT news, forums, messages
Re: problem with php + form + input type = "hidden"

Posted by Gary L. Burnore on 10/17/07 02:24

On Wed, 17 Oct 2007 02:09:51 GMT, dba <dba@somewhere.org> wrote:

>My output is as follows:
>
>*********************************************************************************************
>you entered display1.php
>
>Array ( [cccb_id] => 00007 [selection] => 00008Executive Committee )
>
>selection is: 00008Executive Committee
>member_id is: cccb_id is: 00007
>
>**********************************************************************************************
>
>Now, as you can see from the about output, the array cccb_id indicates
>00007 while I also get 00008 which is correct. The 00007 is the last row
>selected from the database. The name of the committee "Executive
>Committee" is correct. So part of the data being returned is correct by
>part is not. The part that is not is the 'input type="hidden" as
>indicated in the initial thread.

Is it possible the text you quoted isn't as it is in the script?
You've got too many open quotes and spaces between the value of
result['member_id' and the ending quote. That could be enough to
cause your problem. If correcting that doesn't work, post the whole
script (feel free to snip this whole followup to save space).


>Also, I appreciate critical remarks about my code but would like an
>explanation. If I was sloppy enough to make the mistake I probably did
>not know it was sloppy or why it was sloppy. Please elaborate.

When you open an if block, you should close on a line by itself unless
the whole statement fits on one line.

$var = 1;

if ( 1 = $var ) { echo "oh yeah" } ;

would be acceptable but based on what you've posted

if ($field_name == "member_lname") {
echo "Something";
echo "something else";
...
}

Would be less sloppy.

Note the added spaces and indentation. While not required, good for
readability. You likely already know about commenting properly. :)



oh, and one more thing. Please don't top post. Quite annoying.


>
>Gary L. Burnore wrote:
>
>> On Wed, 17 Oct 2007 01:19:43 GMT, dba <dba@somewhere.org> 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 "<input type='radio' name='selection' value=' " .
>>>$result['member_lname']. ',' .$result['member_fname'] ." ' > " .
>>>$result['member_lname'] . ', ' . $result['member_fname'] . "<br />";
>>
>>
>>
>>>echo "<input type='hidden' name='member_id' value=" .
>>>$result['member_id'] . " ' >" . $result['member_id'] . " />" ; }
>>
>>
>> This would return:
>>
>> <input type='hidden' name='member_id' value=NNNN ' > NNNNN />
>>
>> Bet that's not what you want.
>>
>> Oh, and ; } is sloppy programming.
>>
>>
>>
>>
>>
>>
>>>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.
--
gburnore at DataBasix dot Com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
Official .sig, Accept no substitutes. | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ 0 1 7 2 3 / Ý³Þ 3 7 4 9 3 0 Û³
Black Helicopter Repair Services, Ltd.| Official Proof of Purchase
===========================================================================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация