You are here: Re: Newbie - Help please with printing $_POST array « PHP Programming Language « IT news, forums, messages
Re: Newbie - Help please with printing $_POST array

Posted by Andy Jeffries on 05/18/06 16:57

On Thu, 18 May 2006 08:35:34 -0400, David Haynes wrote:
> A trick when using checkboxes is to use a hidden field to record the 'off'
> value, then have the checkbox.

Why bother with that?

> If the checkbox is checked the value will be 'ON'; if the checkbox is
> not set, the value will be whatever you set the hidden value to. ('OFF'
> in the example)

If you don't precede it with a hidden value, it will be either undefined
(normally empty) or the value you chose "ON". So then you continue with
the same code you had before:

> foreach( $_POST as $key => $value ) {
> if( $value == 'ON' ) {
> $del = "delete from catalogue where id = $key"; mysql_query($del) or
> die("...");
> }
> }
> }

I just don't see what practical advantage having a hidden input element
preceding each checkbox gives.

Cheers,


Andy

--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

 

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

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