Reply to Re: - setting checkboxes

Your name:

Reply:


Posted by Jerry Stuckle on 08/07/06 23:57

Jonathan N. Little wrote:
> Sonnich wrote:
>
>>
>> <html>
>> <form method=post name='myform' action='sjjtest.php'><!-- same file -->
>> <table>
>> <?
>> $part1[]="a";
>> $part1[]="b";
>> $part1[]="c";
>> for($i=0; $i<count($part1); $i++)
>> {
>> echo "<td><input name=\"".$part1[$i]."\" type=\"checkbox\"
>> value=\"true\"";
>> if( !(isset($_POST[$part1[$i]])) && ($_POST[$part1[$i]] == "") )
>> echo " checked";
>> echo ">". isset($_POST[$part1[$i]])."-".$_POST[$part1[$i]]
>> ."</td></tr>";
>> }
>> ?>
>> <tr><td><input class="box" name="apply_selection" type="submit" value="
>> Apply selection "></td></tr>
>> </table>
>> </form>
>> </html>
>>
>> Try it and you will see
>>
>
> Not sure what you are trying to accomplish here but in PHP block
> statements need to be surrounded by braces {} therefore it think your
> PHP part should be:
>
>
> <?
> $part1[]="a";
> $part1[]="b";
> $part1[]="c";
> for($i=0; $i<count($part1); $i++)
> {
> echo "<td><input name=\"".$part1[$i]."\" type=\"checkbox\"
> value=\"true\"";
>
> if( !(isset($_POST[$part1[$i]])) && ($_POST[$part1[$i]] == "") )
> { //needed open brace
> echo " checked";
> } //closing brace
>
> echo ">". isset($_POST[$part1[$i]])."-".$_POST[$part1[$i]]
> ."</td></tr>";
> }
> ?>
>
>
> But again not sure what your aim is here....
>

Actually since the body of the if statement is a single statement, the
braces are optional. Only if you have multiple statements in the body
of a loop, if, else, etc. are braces required.

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

[Back to original 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

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