douluozhan4370 2014-10-18 16:29
浏览 126

从select标签的foreach循环创建一个数组,并通过php表单传递它

i dont know how to express it better, but i think my coding show reveal my problem.. am trying to get a select tag list of values from a foreach loop and convert them to an array then pass it using a form post action, i got stuck retrieving the select tag value array from the loop.. heres my code

<form method="post" action="<?php echo base_url();?>index.php?admin/manage_attendance/


<?php 
//STUDENTS ATTENDANCE

 foreach($students as $row)
        {
 ?>

<select name="status" class="form-control" style="width:100px; float:left;">
<option value="0" <?php if($status == 0)echo 'selected="selected"';?>></option>
<option value="1" <?php if($status == 1)echo 'selected="selected"';?>>Present</option>
<option value="2" <?php if($status == 2)echo 'selected="selected"';?>>Absent</option>
</select>


<?php 
} 
?>

<input type="submit" class="btn btn-default"    value="save" style="float:left; margin:0px 10px;">
</form>
  • 写回答

2条回答 默认 最新

  • dsc80135 2014-10-18 16:42
    关注

    your code of

    <select name="status" class="form-control" style="width:100px; float:left;">...
    </select>
    

    is inside of foreach loop, of course it will executed for each loop. Maybe you can put it outside the loop.

    评论

报告相同问题?