You are here: Re: Category checkboxes problem « PHP Programming Language « IT news, forums, messages
Re: Category checkboxes problem

Posted by Geoff Berrow on 03/24/06 21:54

Message-ID: <1143225322.387767.284600@u72g2000cwu.googlegroups.com> from
Ken Robinson contained the following:

>> > <INPUT TYPE="checkbox" NAME="cb123" VALUE="on">Category Description
>> > <INPUT TYPE="checkbox" NAME="cb137" VALUE="on">Category Description
>
>A different way to do this is
>
><INPUT TYPE="checkbox" NAME="cb[123]" VALUE="on">Category Description
><INPUT TYPE="checkbox" NAME="cb[137]" VALUE="on">Category Description
>
>Then in you PHP, you can do
><?php
>if (isset($_POST['cb']))
> foreach $_POST['cb'] as $key=>$dmy)
> echo 'You chose catagory ' . $key . '<br>';
>?>

If he's getting the values from a db it may be slightly easier to do
this:
<INPUT TYPE="checkbox" NAME="cat[]" VALUE="cb123">Category Description
<INPUT TYPE="checkbox" NAME="cat[]" VALUE="cb137">Category Description

<?php
if (isset($_POST['cat'])){
foreach $_POST['cat'] as $value){
echo 'You chose category ' . $value . '<br>';
}
}

Values will only exist if checkboxes are checked.
>?>
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

 

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

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