Home >Backend Development >PHP Tutorial >进来看看这个while循环哪套错了,整个嵌套的循环又重复了一次.

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

WBOY
WBOYOriginal
2016-06-23 14:08:361295browse

进来看看这个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)){ 
    }
  }
}
筛选范围交叉了吧?         

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn