Solved

display array as checkbox list

Posted on 2013-05-31
3
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

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 110

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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

717 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