Re: indexes and arrays
| From: | Richard Lynch | Date: | Tue, 05 Jun 2007 22:59:39 +0000 |
| Subject: | Re: indexes and arrays | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-256142@lists.php.net to get a copy of this message | ||
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?