Double up

3 posts by 2 authors in: Forums > CMS Builder
Last Post: January 22, 2014   (RSS)

By Dave - January 22, 2014

Hey Tim, 

That's a tricky bug.  If you add a <br/> you'll get this: 
echo $list . "<br/>"; //Should list all values checked...

And this output:

A
A B
A B C
A B C D
A B C D E 

Because it's outputting the value as it's incrementally building it up.  So the solution is to print the value _after_ the loop when it's complete: 

<?php

if(!empty($_REQUEST['check_list'])) {
    $list = "";
    foreach($_REQUEST['check_list'] as $check) {
            $list .= "\t".mysql_escape($check)."\t";
    }
    echo $list; //Should list all values checked...
    
}

?>

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By Toledoh - January 22, 2014

Ahhh - that makes perfect sense - thanks!

Cheers,

Tim (toledoh.com.au)