Guys, I know its easy to do it, but I'm having a hard time doing it. Please help me, I want to get the checked items in checkbox. The problem is that it gets the last value of it. I just used echo to get all the values, but how I can get all the values checkedd without using echo, and stored it in another variable. Thank You!

this is the html code

<input type="checkbox" name="sch[]" id="ra" <?php if(isset($sch)) echo "checked"?> value="sample a"/><label>ra sample</label><br><br>
    <input type="checkbox" name="sch[]" id="rb" <?php if(isset($sch)) echo "checked"?>  value="sample b" /><label>rb sample</label><br><br>
    <input type="checkbox" name="sch[]" id="rc" <?php if(isset($sch)) echo "checked"?>  value ="sample c"/><label>rc sample</label><br><br>

    <input type="checkbox" name="sch[]" id="rd" <?php if(isset($sch)) echo "checked"?> value="sample d/><label>rd sample</label><br><br>
    <input type="checkbox" name="sch[]" id="re" <?php if(isset($sch)) echo "checked"?> value="sample e"/><label>re sample</label><br><br>
    <input type="checkbox" name="sch[]" id="rf" <?php if(isset($sch)) echo "checked"?>  onclick="txtShow('txtOSchProg')"/><label>others</label><br><br>

this is the php code

for($i=0;$i<$n; $i++)
{
    $sch = $_SESSION['schp'][$i]. "; ";
    echo $sch;
}

Recommended Answers

All 2 Replies

Will you be able to post the 'txtShow' function too?
Where do you update the $_SESSION['schp'] variable?
If you are trying to do a string concatanation in the for loop, you are missing the '.' before the equal sign.
$sch .= $_SESSION['schp'][$i]. "; ";

Wow, Thank You Sir :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.