Solved

display array as checkbox list

Posted on 2013-05-31
3
334 Views
Last Modified: 2013-05-31
Hi, I have a script as attached. When I run this only the last value is displayed as a checkbox but not the complete array. When I run print_r($ext) and array is displayed :Array ( [0] => 204 [1] => 205 [2] => 207 )  but the check box list only show 207. Help pls? Thank you.

A
 foreach($ext_array as $ext)
     {
                $vSelect ='<input type="checkbox" id="extsn" name="extsn[]" value="' . $ext . '" />' . $ext.'<br />' ."\n";
               
                          }
}

Open in new window

0
Comment
Question by:aej1973
3 Comments
 
LVL 6

Accepted Solution

by:
Robert Saylor earned 350 total points
ID: 39211446
change

$vSelect ='<input type="checkbox" id="extsn" name="extsn[]" value="' . $ext . '" />' . $ext.'<br />' ."\n";

to

$vSelect .='<input type="checkbox" id="extsn" name="extsn[]" value="' . $ext . '" />' . $ext.'<br />' ."\n";
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 50 total points
ID: 39211507
In PHP the single equal sign is the assignment operator.  The single dot is the concatenation operator.  When you use them together like this...

$a .= $b;

... Your telling PHP to take the string value of $b and append it to the rightmost end of the string value of $a, then replace $a with the resulting concatenation.  When you use just the equal sign like this...

$a = $b;

... you're telling PHP to take the data type and value of $b and overwrite $a with it.  It's a common mistake in PHP coding to accidentally omit some of this fiddly punctuation!
0
 

Author Comment

by:aej1973
ID: 39211599
Thank you very much for your quick response. It worked!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now