简体   繁体   中英

Getting the values from multiple chekboxes in an HTML form in php

I have such a code. It is an HTML form:

echo '<b>GPA: </b>'.$yaz["GPA"].'<br>'.'<b>ALES Verbal Score:     
</b>'.$yaz["ALES_VERBAL_SCORES"].'<br>'.'<b>Ales Math Score:     
</b>'.$yaz["ALES_MATH_SCORE"].'<br>'.'<b>ALES Equal Weight Score:     
</b>'.$yaz["ALES_EQUALWEIGHT_SCORES"].'<br>'.'<b>TOEFL PBT:     
</b>'.$yaz["TOEFL_PBT"].'<br>'.'<b>TOEFL CBT:     
</b>'.$yaz["TOEFL_CBT"].'<br>'.'<b>TOEFL     
IBT:    
</b>'.$yaz["TOEFL_IBT"].'<br>'.'<b>IELTS: </b>'.$yaz["IELTS"].'<br>'.'
<br><input type="checkbox" value="'.$yaz["NAME"].'" name="check_'.$counter.'" />'.'
<div class="clear"></div></div>';

As you notice, there is a checkbox input at the end of the "echo" code. I want to get the value of checkbox for each loop and list them. How can I manage it? Thanks...

instead of using this

'<input type="checkbox" value="'.$yaz["NAME"].'" name="check_'.$counter.'" />'

you can just use

<input type="checkbox" value="'.$yaz["NAME"].'" name="check[]" />'

while you submit the form you can access it as

$_POST['check']

and it ll come as an array in order

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM