>백엔드 개발 >PHP 튜토리얼 >进来看看这个while循环哪套错了,整个嵌套的循环又重复了一次.

进来看看这个while循环哪套错了,整个嵌套的循环又重复了一次.

WBOY
WBOY원래의
2016-06-23 14:08:361296검색

进来看看这个while循环哪套错了,整个嵌套的循环又重复了一次...
重重复效果如下图所示,

<label>	<select name="upname"><option value="">-请选择-</option>			<option value="0">-顶级-</option>            <?php $query = "select * from tbl_department where dpUpID ='0'";				$query_info = mysql_query($query);				while($row = mysql_fetch_array($query_info)){  ?>				<option value="<?php echo "$row[dpName]";?>">    <?php echo "$row[dpName]";?></option>				<?php $query_1 = "select * from tbl_department where dpUpID = '$row[dpName]'";					$query_info_1 = mysql_query($query_1);					while($row_1 = mysql_fetch_array($query_info_1)){  ?>				<option value="<?php echo "$row_1[ID]";?>"><?php echo "$row_1[dpName]";?></option>					<?php $query_2 = "select * from tbl_department where dpUpID = '$row_1[ID]'";					$query_info_2 = mysql_query($query_2);					while($row_2 = mysql_fetch_array($query_info_2)){  ?>				<option value="<?php echo "$row_2[ID]";?>"><?PHP echo "$row_2[dpName]";?></option>								       <?php }}}?>										            			</select></label>


回复讨论(解决方案)

$query = "select * from tbl_department where dpUpID ='0'";
$query_info = mysql_query($query);
while($row = mysql_fetch_array($query_info)){
  $query_1 = "select * from tbl_department where dpUpID = ' $row[dpName]'";
  $query_info_1 = mysql_query($query_1);
  while($row_1 = mysql_fetch_array($query_info_1)){
    $query_2 = "select * from tbl_department where dpUpID = ' $row_1[ID]'";
    $query_info_2 = mysql_query($query_2);
    while($row_2 = mysql_fetch_array($query_info_2)){ 
    }
  }
}
筛选范围交叉了吧?         

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.