首页 >后端开发 >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