2012-01-09 96 views
0

我想列出每个项目旁边的复选框。出于某种原因,我可以打印列表,但复选框没有显示出来。PHP列表和复选框

$note = mysql_fetch_array($note_content); 

if($note['type'] == 'list') 
{ 
    $note_type='list';  

    print "<dl>"; 
    while($note = mysql_fetch_array($note_content)) 
    { 
     if($note['complete']) 
      echo "<strike>"; 
     echo "<dt>".$note['body']."</dt>"; 
     if($note['complete']) 
      echo "</strike>"; 
    } 
    print "</dl>"; 

    print "<dl style=\"float:right\">"; 
    while($note = mysql_fetch_array($note_content)) 
    { 
     echo "<dt> 
     <input type='checkbox' name='complete_goal' value='".$note['note_id']."'> 
     </input> 
     </dt>"; 
    } 
    print "</dl>"; 
} 
else 
{ 
    echo $note['body']; 
} 

回答

0

使用mysql_data_seek({result set},{record#})将你的结果重置为阵列的顶部,这样你就可以重新处理与 while($note = mysql_fetch_array($note_content))或其他阵列处理。

0

mysql_fetch_array将内部数据指针向前移动。在您的第二条while声明中,请不要使用$note = mysql_fetch_array($note_content),而应尝试reset($note)。这会将内部指针设置为第一个数据元素。你的第二个while循环

EG: 
mysql_data_seek($note_content, 0) 
("0" represents the first record in the array.) 

此之前

+0

这给了我一个无限循环的复选框。 – 2012-01-09 06:20:04