Re: indexes and arrays

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

 




On Tue, June 5, 2007 10:01 am, blueboy wrote:
>    I have an array of facilities, how do I define them all in one go
> so I do
> not get the undefined index error?
>
>

http://php.net/isset

You also could make an array of checkboxes instead of hand-typing all
that...

$facilities = array(5=>'Credit Cards Accepted', 6=>'Towels',
7=>'Luggage Storage');

foreach($facilities as $f_id => $f_name){
  $checked = isset($_POST['facilitiies'][$f_id]) ? 'checked="checked"
: '';
  ?><input name="facilities[<?php echo $f_id?>]" <?php echo $checked?>
/><?php
}

> input name="facilities[5] " type="checkbox" id="facilities[5] "
> value="Credit Cards Accepted" <?php if ($_POST['facilities'][5]!='') {
> echo
> 'checked="checked" '; }?>>
>       Credit Cards Accepted </td>
>     <td><input name="facilities[6] " type="checkbox" id="facilities[6]
> "
> value="Towels" <?php if ($_POST['facilities'][6]!='') { echo
> 'checked="checked" '; }?>>
>       Towels </td>
>     <td><input name="facilities[7] " type="checkbox" id="facilities[7]
> "
> value="Luggage Storage" <?php if ($_POST['facilities'][7]!='') { echo
> 'checked="checked" '; }?>>
>       Luggage Storage </td>
>     <td><input name="facilities[8] " type="checkbox" id="facilities[8]
> "
> value="Telephone/Fax Facilities" <?php if
> ($_POST['facilities'][8]!='') {
> echo 'checked="checked" '; }?>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux