Re: a php code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2004-07-26 at 13:04, Hongwei Li wrote:

> Here is my test code, called fm.php:
> 
> <?php
> if (!isset($pick)) {
>  echo "Select color(s) and submit the form below."; }
> else {
>  $j = count($pick);
>  for($i=0; $i<$j; $i++) {
>   echo "Pick <b>$pick[$i]</b> is Checked<br />"; }
>  }
> ?>
> 
> <form action="<?php echo $_SERVER['PHP_SELF']; ?>">
> <ol>
> <li>Red<input name="pick[]" type=checkbox value="Red" /></li>
> <li>Blue<input name="pick[]" type=checkbox value="Blue" /></li>
> <li>Yellow<input name="pick[]" type=checkbox value="Yellow" /></li>
> </ol>
> 
> <input type="submit" value="Submit!" />
> <input type="reset" value="Reset" />
> </form>
> 
> When I test it, the browser displays the form with "Select color(s) and
> submit the form below.", and the browser address box shows 
> http://.../fm.php
> 

pick is being used as an array in your form but I think the test is
looking at it as a regular variable which isset is most likely always
evaluating as true.

You can test if each element in the array is set isset($pick[0]) etc
but I don't think testing on the name of the array will give you what
you want.

You will need to iterate through the array testing each value.

An excellent place for info on php is http://www.php.net.  They have
have a lot of good examples and you can search for information on
various functions very easily.

-- 
Scot L. Harris
webid@xxxxxxxxxx

You can fool some of the people all of the time,
and all of the people some of the time,
but you can make a fool of yourself anytime. 



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux