php for循环的这段代码为什么不执行??

来源:百度知道 编辑:UC知道 时间:2024/09/22 06:48:40
<?php for($i=0;$i<total;$i++){
$sun_re=$db->query("select * from t_pub_surevy_question where parent_question_id=$sun_rs[$i]['id']");
$sun_result=$sun_re->fetchAll();
?>
<li><?php echo $sun_rs[$i]['title']?></li>
<table>
<tr>
<td>
<ol style="list-style-type:upper-alpha" >
<?php foreach($sun_result as $rows){?>
<li ><?php if($type==1){?>
<input type="radio" name="radio" value="<?php echo $rows['id']?>"><?php echo $rows['answer']?>
<?php }if($type==2){ ?>
<input type="radio" name="checkbox" value="<?php echo $rows['id']?>"><?php echo $rows['answer']

for($i=0;$i<total;$i++){
好像是丢了一个$符号,应该修改为:
for($i=0;$i<$total;$i++){

对于引号里面的数组变量,应该使用{},例如:
"select * from t_pub_surevy_question where parent_question_id=$sun_rs[$i]['id']"
应该修改为:
("select * from t_pub_surevy_question where parent_question_id={$sun_rs[$i]['id']}");

total应改为$total