Why this loop?

I have this

<?php
session_start();

$asset_id = (int)$_GET['id'];

include '../../../../../../db/pdo_conn.php'; 
if(isset($_POST['loginSubmit'])){ // Check if form was submitted

      $myusername = $_POST['Email'];
      $mypassword = $_POST['Password']; 
      
	try{
  
	$sql = "SELECT user_id, pass, email, role FROM users WHERE email = '".$myusername."' and pass = '".$mypassword."' and operational_status = 1";
	//echo $sql;
	$result = $pdo->query($sql);
	
		if($result->rowCount() > 0){

			while($row = $result->fetch()){    

			 $_SESSION['email'] = $myusername;
			 $_SESSION['user_id'] = $row['user_id'];
			 $_SESSION['user_role'] = $row['role'];
			 $_SESSION['id'] = session_id();
			 }
		}
	} catch(PDOException $e){
		die("ERROR: Could not able to execute $sql. " . $e->getMessage());
	}
}
	try {
	$sql = 'SELECT assets.name,assets.operational_status,materials.power,
			materials.name,materials.manufacturer,materials.model,materials.width,materials.height,materials.depth,materials.ports,materials.material_id,materials.type,
			racks.name AS rack_Name,racks.rack_id,rooms.name AS room_Name,rooms.room_id,buildings.name AS building_Name,buildings.building_id,locations.name AS location_Name,
			sites.site_id,sites.name AS site_Name,locations.location_id,beginning_ru,ending_ru,materials.ports
			FROM assets
			INNER JOIN materials ON assets.material_id = materials.material_id
			INNER JOIN racks ON assets.material_id = materials.material_id
			INNER JOIN rooms ON racks.room_id = rooms.room_id
			INNER JOIN buildings ON rooms.building_id = buildings.building_id
			INNER JOIN sites ON buildings.site_id = sites.site_id
			INNER JOIN locations ON sites.location_id = locations.location_id
			WHERE asset_id = '.$asset_id;
			$result = $pdo->query($sql);
			
		if($result->rowCount() > 0){

			while($row = $result->fetch()){
							  
				switch ($row['type']) {
				  case 'Chassis':
					$material_img = "chassis_icon.png";
				  break;
				  case 'KVM':
					$material_img = "kvm_icon.png";
				  break;
				  case 'Server':
					$material_img = "server_icon.png";
				  break;
				  case 'Storage':
					$material_img = "storage_icon.png";
				  break;
				  case 'Unknown':
					$material_img = "unknown_icon.png";
				  break;
				  default:
					die('Type not recognized.');
				}
?>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>AutoCad Automation Tool - <?=$row['type']?></title>
	<link href="../../../../../../css/bootstrap.min.css" rel="stylesheet">        
	<link href="../../../../../../css/font-awesome.min.css" rel="stylesheet">        
	<link href="../../../../../../css/style.css" rel="stylesheet">        
	<link href="../../../../../../css/tabs.css" rel="stylesheet">   
	<script src="../../../../../../js/bootstrap.bundle.min.js"></script> 
<style>
	.tipthemewhite {margin:3em 0 0 1.1em;}
*[data-href] {
  cursor: pointer;
}
td a {
  display:inline-block;
  min-height:100%;
  width:100%;
  color:#999;
}
td a:hover {
	text-decoration:none;
	color:#000;
}
td {
  padding:0;  
}
	</style>	
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-3">
  <a class="navbar-brand" href="../../../../../../index.php">AutoCad Automation Tool</a>
  <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  <span class="navbar-toggler-icon"></span>
  </button>
	<div class="collapse navbar-collapse" id="navbarSupportedContent">
	    <ul class="navbar-nav mr-auto">
		<li class="nav-item">
		  <a class="nav-link" href="../../../../../../locations">Locations</a>
		</li>
        <li class="nav-item">
		  <a class="nav-link" href="../../../../../../projects">Projects</a>
		</li>	  
         </ul>
	</div>
</nav>
<div class="container-fluid">
    <div class="row">
        <div class="col">  
		    <div class="card">
			  <h2 class="card-header"><img src="../../../../../../images/<?=$material_img?>" width="40" alt="<?=$row['type']?>">  <?=$row['type']?>: <span class="text-secondary"><?=$row['name']?></span>
			  <small class="float-end text-secondary"><span class="icon-random"></span>&nbsp;&nbsp;Moving Asset</small>		  
			  </h2>
			    <div class="card-body p-0">
				    <div class="container-fluid">
						<div class="row">
							<div class="col pt-3">  
							  <h3 class="text-secondary ms-3">From:</h3>
							  <hr>
								<div class="row">
									<div class="col">  
										<div class="row m-3">
											<div class="col"> 
											<h5><span class="icon-map-marker"></span>&nbsp;&nbsp;&nbsp;Location:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../../../../show_location.php?id=<?=$row['location_id']?>"><?=$row['location_Name']?></a></h5>
											</div>
										</div>
										<div class="row m-3">
											<div class="col"> 
											<h5><span class="icon-bullseye"></span>&nbsp;&nbsp;Site:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../../../show_site.php?id=<?=$row['site_id']?>"><?=$row['site_Name']?></a></h5>
											</div>
										</div>
										<div class="row m-3">
											<div class="col"> 									    
											<h5><img src="../../../../../../images/building.svg" alt="building">&nbsp;&nbsp;Building:</h5> 
											</div>
											<div class="col"> 
											<h5><a href="../../../show_building.php?id=<?=$row['building_id']?>"><?=$row['building_Name']?></a></h5>
											</div>
										</div>
										<div class="row m-3">
											<div class="col"> 
											<h5><img src="../../../../../../images/room.png" width="18" alt="Room">&nbsp;&nbsp;Room:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../show_room.php?id=<?=$row['room_id']?>"><?=$row['room_Name']?></a></h5>
											</div>								 
										</div>
										<div class="row m-3">
											<div class="col"> 
											<h5><img src="../../../../../../images/rack.svg" width="18" alt="Rack">&nbsp;&nbsp;Rack:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../show_rack.php?id=<?=$row['rack_id']?>"><?=$row['rack_Name']?></a></h5>
											</div>								 
										</div>							 
									</div>
									<div class="col">
									
									</div>
								</div>							 
							</div>
						    <div class="col border-start pt-3">
							  <h3 class="text-secondary ms-3">To</h3>
							  <hr>
								<div class="row">
									<div class="col"> 
									  <form action="move_asset_engine.php" method="POST">									
										<div class="row mb-3">
											<div class="col"> 
											<h5 class="ms-3"><span class="icon-map-marker"></span>&nbsp;&nbsp;&nbsp;Location:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../../../../show_location.php?id=<?=$row['location_id']?>"><?=$row['location_Name']?></a></h5>
											</div>
										</div>
										<div class="row mb-3">
											<div class="col"> 
											<h5 class="ms-3"><span class="icon-bullseye"></span>&nbsp;&nbsp;Site:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../../../show_site.php?id=<?=$row['site_id']?>"><?=$row['site_Name']?></a></h5>
											</div>
										</div>								
										<div class="row mb-3">
											<div class="col">
											  <h5 class="ms-3"><img src="../../../../../../images/building.svg" width="18" alt="building">&nbsp;&nbsp;Building:</h5>
											</div>
											<div class="col">
												<div class="input-group input-group-sm">
													<div class="input-group-prepend">
													  <span class="input-group-text text-secondary"><span class="icon-search"></span></span>
													</div>	
												  <select class="form-control" id="to_asset_building" name="to_asset_building" required>	
												  <option value='' disabled selected hidden>Select</option>
<?php      
try{
$sql = 'SELECT name,building_id	FROM buildings WHERE site_id = '.$row["site_id"];
		
$buildings_result = $pdo->query($sql);

    if($buildings_result->rowCount() > 0){
        while($building_row = $buildings_result->fetch()){
        echo "<option value='".$building_row['building_id']."'>".$building_row['name']."</option>";
        }
    } else{
        echo "<option value=''>None found</option>";
    }
} catch(PDOException $e){
    die("ERROR: Could not able to execute $sql. " . $e->getMessage());
}
			
?>					
												  </select>
												</div>
											</div>
										</div>									
										<div class="row mb-3">
											<div class="col">
											  <h5 class="ms-3"><img src="../../../../../../images/room.png" width="18" alt='room'>&nbsp;&nbsp;Room:</h5>
											</div>
											<div class="col">
												<div class="input-group input-group-sm">
													<div class="input-group-prepend">
													  <span class="input-group-text text-secondary"><span class="icon-search"></span></span>
													</div>	
												  <select class="form-control" id="to_asset_room" name="to_asset_room">					
												  </select>
												</div>
											</div>
										</div>
										<div class="row mb-3">
											<div class="col">												  
											  <h5 class="ms-3"><img src="../../../../../../images/rack.svg" width="18" alt='rack'>&nbsp;&nbsp;Rack:</h5>
											</div>
											<div class="col">
												<div class="input-group input-group-sm">
													<div class="input-group-prepend">
													  <span class="input-group-text text-secondary"><span class="icon-search"></span></span>
													</div>	
												  <select class="form-control" id="to_asset_rack" name="to_asset_rack">	
												  </select>
												</div>
											</div>
										</div>
										<div class="row mb-3">
											<div class="d-grid">
												<button class="btn btn-outline-dark btn-lg" type="submit"><span class="icon-ok"></span>&nbsp;&nbsp;Submit</button>
											</div>
										</div>				
									  <input type="hidden" value="<?=$asset_id?>" name="asset_id">
									  </form>
									</div>
									<div class="col">

			
									</div>							 
								</div>
					   
						   </div>
					    </div>
					</div>
				</div>
			</div>
		 </div>
    </div>
</div>
<?php
if(isset($_POST['loginSubmit'])){ // Check if form was submitted
echo '<script>';
echo 'document.addEventListener("DOMContentLoaded", function(event){';
echo 'document.getElementById("close_login").click();';
echo '});';
echo '</script>';
}
?>
<script>
	document.getElementById('to_asset_building').addEventListener('change',postRooms);

function postRooms(e){
  e.preventDefault();

  var xhr = new XMLHttpRequest();
  xhr.open('POST', 'roomOptions.php');
  xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

  xhr.onload = function(){
	document.getElementById('to_asset_room').innerHTML = this.responseText;
  }
  xhr.send("building_id="+document.getElementById('to_asset_building').value);

}
	document.getElementById('to_asset_room').addEventListener('change',postRacks);

function postRacks(e){
  e.preventDefault();

  var xhr = new XMLHttpRequest();
  xhr.open('POST', 'rackOptions.php');
  xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

  xhr.onload = function(){
	document.getElementById('to_asset_rack').innerHTML = this.responseText;
  }
  xhr.send("room_id="+document.getElementById('to_asset_room').value);

}
	document.getElementById('to_asset_rack').addEventListener('change',postAssets);

function postAssets(e){
  e.preventDefault();

  var xhr = new XMLHttpRequest();
  xhr.open('POST', 'asset_options.php');
  xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

  xhr.onload = function(){
	document.getElementById('to_asset_id').innerHTML = this.responseText;
  }

  xhr.send("rack_id="+document.getElementById('to_asset_rack').value);

}

</script>
</body>
</html>
<?php		
			}
	unset($result);
		} else{
		 echo '<h>Asset not found.</h1>';
		}
	} catch(PDOException $e){
		die("ERROR: Could not able to execute $sql. " . $e->getMessage());
	}

// Close connection
unset($pdo);
?>

but, heres the result…


<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>AutoCad Automation Tool - KVM</title>
	<link href="../../../../../../css/bootstrap.min.css" rel="stylesheet">        
	<link href="../../../../../../css/font-awesome.min.css" rel="stylesheet">        
	<link href="../../../../../../css/style.css" rel="stylesheet">        
	<link href="../../../../../../css/tabs.css" rel="stylesheet">   
	<script src="../../../../../../js/bootstrap.bundle.min.js"></script> 
<style>
	.tipthemewhite {margin:3em 0 0 1.1em;}
*[data-href] {
  cursor: pointer;
}
td a {
  display:inline-block;
  min-height:100%;
  width:100%;
  color:#999;
}
td a:hover {
	text-decoration:none;
	color:#000;
}
td {
  padding:0;  
}
	</style>	
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-3">
  <a class="navbar-brand" href="../../../../../../index.php">AutoCad Automation Tool</a>
  <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  <span class="navbar-toggler-icon"></span>
  </button>
	<div class="collapse navbar-collapse" id="navbarSupportedContent">
	    <ul class="navbar-nav mr-auto">
		<li class="nav-item">
		  <a class="nav-link" href="../../../../../../locations">Locations</a>
		</li>
        <li class="nav-item">
		  <a class="nav-link" href="../../../../../../projects">Projects</a>
		</li>	  
         </ul>
	</div>
</nav>
<div class="container-fluid">
    <div class="row">
        <div class="col">  
		    <div class="card">
			  <h2 class="card-header"><img src="../../../../../../images/kvm_icon.png" width="40" alt="KVM">  KVM: <span class="text-secondary">Rabbit</span>
			  <small class="float-end text-secondary"><span class="icon-random"></span>&nbsp;&nbsp;Moving Asset</small>		  
			  </h2>
			    <div class="card-body p-0">
				    <div class="container-fluid">
						<div class="row">
							<div class="col pt-3">  
							  <h3 class="text-secondary ms-3">From:</h3>
							  <hr>
								<div class="row">
									<div class="col">  
										<div class="row m-3">
											<div class="col"> 
											<h5><span class="icon-map-marker"></span>&nbsp;&nbsp;&nbsp;Location:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../../../../show_location.php?id=1">gdfg</a></h5>
											</div>
										</div>
										<div class="row m-3">
											<div class="col"> 
											<h5><span class="icon-bullseye"></span>&nbsp;&nbsp;Site:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../../../show_site.php?id=1">erd</a></h5>
											</div>
										</div>
										<div class="row m-3">
											<div class="col"> 									    
											<h5><img src="../../../../../../images/building.svg" alt="building">&nbsp;&nbsp;Building:</h5> 
											</div>
											<div class="col"> 
											<h5><a href="../../../show_building.php?id=1">gdhjghj</a></h5>
											</div>
										</div>
										<div class="row m-3">
											<div class="col"> 
											<h5><img src="../../../../../../images/room.png" width="18" alt="Room">&nbsp;&nbsp;Room:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../show_room.php?id=1">test</a></h5>
											</div>								 
										</div>
										<div class="row m-3">
											<div class="col"> 
											<h5><img src="../../../../../../images/rack.svg" width="18" alt="Rack">&nbsp;&nbsp;Rack:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../show_rack.php?id=3">Luke Urtnowski</a></h5>
											</div>								 
										</div>							 
									</div>
									<div class="col">
									
									</div>
								</div>							 
							</div>
						    <div class="col border-start pt-3">
							  <h3 class="text-secondary ms-3">To</h3>
							  <hr>
								<div class="row">
									<div class="col">  
										<div class="row mb-3">
											<div class="col"> 
											<h5 class="ms-3"><span class="icon-map-marker"></span>&nbsp;&nbsp;&nbsp;Location:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../../../../show_location.php?id=1">gdfg</a></h5>
											</div>
										</div>
										<div class="row mb-3">
											<div class="col"> 
											<h5 class="ms-3"><span class="icon-bullseye"></span>&nbsp;&nbsp;Site:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../../../show_site.php?id=1">erd</a></h5>
											</div>
										</div>								
										<div class="row mb-3">
											<div class="col">
											  <h5 class="ms-3"><img src="../../../../../../images/building.svg" width="18" alt="building">&nbsp;&nbsp;Building:</h5>
											</div>
											<div class="col">
												<div class="input-group input-group-sm">
													<div class="input-group-prepend">
													  <span class="input-group-text text-secondary"><span class="icon-search"></span></span>
													</div>	
												  <select class="form-control" id="to_asset_building" name="to_asset_building" required>	
												  <option value='' disabled selected hidden>Select</option>
<option value='1'>gdhjghj</option>					
												  </select>
												</div>
											</div>
										</div>									
										<div class="row mb-3">
											<div class="col">
											  <h5 class="ms-3"><img src="../../../../../../images/room.png" width="18" alt='room'>&nbsp;&nbsp;Room:</h5>
											</div>
											<div class="col">
												<div class="input-group input-group-sm">
													<div class="input-group-prepend">
													  <span class="input-group-text text-secondary"><span class="icon-search"></span></span>
													</div>	
												  <select class="form-control" id="to_asset_room" name="to_asset_room">					
												  </select>
												</div>
											</div>
										</div>
										<div class="row mb-3">
											<div class="col">												  
											  <h5 class="ms-3"><img src="../../../../../../images/rack.svg" width="18" alt='rack'>&nbsp;&nbsp;Rack:</h5>
											</div>
											<div class="col">
												<div class="input-group input-group-sm">
													<div class="input-group-prepend">
													  <span class="input-group-text text-secondary"><span class="icon-search"></span></span>
													</div>	
												  <select class="form-control" id="to_asset_rack" name="to_asset_rack">	
												  </select>
												</div>
											</div>
										</div>
										<div class="row mb-3">
											<div class="d-grid">
												<button class="btn btn-outline-dark btn-lg" type="submit"><span class="icon-ok"></span>&nbsp;&nbsp;Submit</button>
											</div>
										</div>				
										<input type="hidden" value="1" name="asset_id">
										</form>
									</div>
									<div class="col">

			
									</div>							 
								</div>
					   
						   </div>
					    </div>
					</div>
				</div>
			</div>
		 </div>
    </div>
</div>
<script>
	document.getElementById('to_asset_building').addEventListener('change',postRooms);

function postRooms(e){
  e.preventDefault();

  var xhr = new XMLHttpRequest();
  xhr.open('POST', 'roomOptions.php');
  xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

  xhr.onload = function(){
	document.getElementById('to_asset_room').innerHTML = this.responseText;
  }
  xhr.send("building_id="+document.getElementById('to_asset_building').value);

}
	document.getElementById('to_asset_room').addEventListener('change',postRacks);

function postRacks(e){
  e.preventDefault();

  var xhr = new XMLHttpRequest();
  xhr.open('POST', 'rackOptions.php');
  xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

  xhr.onload = function(){
	document.getElementById('to_asset_rack').innerHTML = this.responseText;
  }
  xhr.send("room_id="+document.getElementById('to_asset_room').value);

}
	document.getElementById('to_asset_rack').addEventListener('change',postAssets);

function postAssets(e){
  e.preventDefault();

  var xhr = new XMLHttpRequest();
  xhr.open('POST', 'asset_options.php');
  xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

  xhr.onload = function(){
	document.getElementById('to_asset_id').innerHTML = this.responseText;
  }

  xhr.send("rack_id="+document.getElementById('to_asset_rack').value);

}

</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>AutoCad Automation Tool - KVM</title>
	<link href="../../../../../../css/bootstrap.min.css" rel="stylesheet">        
	<link href="../../../../../../css/font-awesome.min.css" rel="stylesheet">        
	<link href="../../../../../../css/style.css" rel="stylesheet">        
	<link href="../../../../../../css/tabs.css" rel="stylesheet">   
	<script src="../../../../../../js/bootstrap.bundle.min.js"></script> 
<style>
	.tipthemewhite {margin:3em 0 0 1.1em;}
*[data-href] {
  cursor: pointer;
}
td a {
  display:inline-block;
  min-height:100%;
  width:100%;
  color:#999;
}
td a:hover {
	text-decoration:none;
	color:#000;
}
td {
  padding:0;  
}
	</style>	
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-3">
  <a class="navbar-brand" href="../../../../../../index.php">AutoCad Automation Tool</a>
  <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  <span class="navbar-toggler-icon"></span>
  </button>
	<div class="collapse navbar-collapse" id="navbarSupportedContent">
	    <ul class="navbar-nav mr-auto">
		<li class="nav-item">
		  <a class="nav-link" href="../../../../../../locations">Locations</a>
		</li>
        <li class="nav-item">
		  <a class="nav-link" href="../../../../../../projects">Projects</a>
		</li>	  
         </ul>
	</div>
</nav>
<div class="container-fluid">
    <div class="row">
        <div class="col">  
		    <div class="card">
			  <h2 class="card-header"><img src="../../../../../../images/kvm_icon.png" width="40" alt="KVM">  KVM: <span class="text-secondary">Rabbit</span>
			  <small class="float-end text-secondary"><span class="icon-random"></span>&nbsp;&nbsp;Moving Asset</small>		  
			  </h2>
			    <div class="card-body p-0">
				    <div class="container-fluid">
						<div class="row">
							<div class="col pt-3">  
							  <h3 class="text-secondary ms-3">From:</h3>
							  <hr>
								<div class="row">
									<div class="col">  
										<div class="row m-3">
											<div class="col"> 
											<h5><span class="icon-map-marker"></span>&nbsp;&nbsp;&nbsp;Location:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../../../../show_location.php?id=1">gdfg</a></h5>
											</div>
										</div>
										<div class="row m-3">
											<div class="col"> 
											<h5><span class="icon-bullseye"></span>&nbsp;&nbsp;Site:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../../../show_site.php?id=1">erd</a></h5>
											</div>
										</div>
										<div class="row m-3">
											<div class="col"> 									    
											<h5><img src="../../../../../../images/building.svg" alt="building">&nbsp;&nbsp;Building:</h5> 
											</div>
											<div class="col"> 
											<h5><a href="../../../show_building.php?id=1">gdhjghj</a></h5>
											</div>
										</div>
										<div class="row m-3">
											<div class="col"> 
											<h5><img src="../../../../../../images/room.png" width="18" alt="Room">&nbsp;&nbsp;Room:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../show_room.php?id=2">Luke Urtnowski</a></h5>
											</div>								 
										</div>
										<div class="row m-3">
											<div class="col"> 
											<h5><img src="../../../../../../images/rack.svg" width="18" alt="Rack">&nbsp;&nbsp;Rack:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../show_rack.php?id=1">Luke Urtnowski</a></h5>
											</div>								 
										</div>							 
									</div>
									<div class="col">
									
									</div>
								</div>							 
							</div>
						    <div class="col border-start pt-3">
							  <h3 class="text-secondary ms-3">To</h3>
							  <hr>
								<div class="row">
									<div class="col">  
										<div class="row mb-3">
											<div class="col"> 
											<h5 class="ms-3"><span class="icon-map-marker"></span>&nbsp;&nbsp;&nbsp;Location:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../../../../show_location.php?id=1">gdfg</a></h5>
											</div>
										</div>
										<div class="row mb-3">
											<div class="col"> 
											<h5 class="ms-3"><span class="icon-bullseye"></span>&nbsp;&nbsp;Site:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../../../show_site.php?id=1">erd</a></h5>
											</div>
										</div>								
										<div class="row mb-3">
											<div class="col">
											  <h5 class="ms-3"><img src="../../../../../../images/building.svg" width="18" alt="building">&nbsp;&nbsp;Building:</h5>
											</div>
											<div class="col">
												<div class="input-group input-group-sm">
													<div class="input-group-prepend">
													  <span class="input-group-text text-secondary"><span class="icon-search"></span></span>
													</div>	
												  <select class="form-control" id="to_asset_building" name="to_asset_building" required>	
												  <option value='' disabled selected hidden>Select</option>
<option value='1'>gdhjghj</option>					
												  </select>
												</div>
											</div>
										</div>									
										<div class="row mb-3">
											<div class="col">
											  <h5 class="ms-3"><img src="../../../../../../images/room.png" width="18" alt='room'>&nbsp;&nbsp;Room:</h5>
											</div>
											<div class="col">
												<div class="input-group input-group-sm">
													<div class="input-group-prepend">
													  <span class="input-group-text text-secondary"><span class="icon-search"></span></span>
													</div>	
												  <select class="form-control" id="to_asset_room" name="to_asset_room">					
												  </select>
												</div>
											</div>
										</div>
										<div class="row mb-3">
											<div class="col">												  
											  <h5 class="ms-3"><img src="../../../../../../images/rack.svg" width="18" alt='rack'>&nbsp;&nbsp;Rack:</h5>
											</div>
											<div class="col">
												<div class="input-group input-group-sm">
													<div class="input-group-prepend">
													  <span class="input-group-text text-secondary"><span class="icon-search"></span></span>
													</div>	
												  <select class="form-control" id="to_asset_rack" name="to_asset_rack">	
												  </select>
												</div>
											</div>
										</div>
										<div class="row mb-3">
											<div class="d-grid">
												<button class="btn btn-outline-dark btn-lg" type="submit"><span class="icon-ok"></span>&nbsp;&nbsp;Submit</button>
											</div>
										</div>				
										<input type="hidden" value="1" name="asset_id">
										</form>
									</div>
									<div class="col">

			
									</div>							 
								</div>
					   
						   </div>
					    </div>
					</div>
				</div>
			</div>
		 </div>
    </div>
</div>
<script>
	document.getElementById('to_asset_building').addEventListener('change',postRooms);

function postRooms(e){
  e.preventDefault();

  var xhr = new XMLHttpRequest();
  xhr.open('POST', 'roomOptions.php');
  xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

  xhr.onload = function(){
	document.getElementById('to_asset_room').innerHTML = this.responseText;
  }
  xhr.send("building_id="+document.getElementById('to_asset_building').value);

}
	document.getElementById('to_asset_room').addEventListener('change',postRacks);

function postRacks(e){
  e.preventDefault();

  var xhr = new XMLHttpRequest();
  xhr.open('POST', 'rackOptions.php');
  xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

  xhr.onload = function(){
	document.getElementById('to_asset_rack').innerHTML = this.responseText;
  }
  xhr.send("room_id="+document.getElementById('to_asset_room').value);

}
	document.getElementById('to_asset_rack').addEventListener('change',postAssets);

function postAssets(e){
  e.preventDefault();

  var xhr = new XMLHttpRequest();
  xhr.open('POST', 'asset_options.php');
  xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

  xhr.onload = function(){
	document.getElementById('to_asset_id').innerHTML = this.responseText;
  }

  xhr.send("rack_id="+document.getElementById('to_asset_rack').value);

}

</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>AutoCad Automation Tool - KVM</title>
	<link href="../../../../../../css/bootstrap.min.css" rel="stylesheet">        
	<link href="../../../../../../css/font-awesome.min.css" rel="stylesheet">        
	<link href="../../../../../../css/style.css" rel="stylesheet">        
	<link href="../../../../../../css/tabs.css" rel="stylesheet">   
	<script src="../../../../../../js/bootstrap.bundle.min.js"></script> 
<style>
	.tipthemewhite {margin:3em 0 0 1.1em;}
*[data-href] {
  cursor: pointer;
}
td a {
  display:inline-block;
  min-height:100%;
  width:100%;
  color:#999;
}
td a:hover {
	text-decoration:none;
	color:#000;
}
td {
  padding:0;  
}
	</style>	
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-3">
  <a class="navbar-brand" href="../../../../../../index.php">AutoCad Automation Tool</a>
  <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  <span class="navbar-toggler-icon"></span>
  </button>
	<div class="collapse navbar-collapse" id="navbarSupportedContent">
	    <ul class="navbar-nav mr-auto">
		<li class="nav-item">
		  <a class="nav-link" href="../../../../../../locations">Locations</a>
		</li>
        <li class="nav-item">
		  <a class="nav-link" href="../../../../../../projects">Projects</a>
		</li>	  
         </ul>
	</div>
</nav>
<div class="container-fluid">
    <div class="row">
        <div class="col">  
		    <div class="card">
			  <h2 class="card-header"><img src="../../../../../../images/kvm_icon.png" width="40" alt="KVM">  KVM: <span class="text-secondary">Rabbit</span>
			  <small class="float-end text-secondary"><span class="icon-random"></span>&nbsp;&nbsp;Moving Asset</small>		  
			  </h2>
			    <div class="card-body p-0">
				    <div class="container-fluid">
						<div class="row">
							<div class="col pt-3">  
							  <h3 class="text-secondary ms-3">From:</h3>
							  <hr>
								<div class="row">
									<div class="col">  
										<div class="row m-3">
											<div class="col"> 
											<h5><span class="icon-map-marker"></span>&nbsp;&nbsp;&nbsp;Location:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../../../../show_location.php?id=1">gdfg</a></h5>
											</div>
										</div>
										<div class="row m-3">
											<div class="col"> 
											<h5><span class="icon-bullseye"></span>&nbsp;&nbsp;Site:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../../../show_site.php?id=1">erd</a></h5>
											</div>
										</div>
										<div class="row m-3">
											<div class="col"> 									    
											<h5><img src="../../../../../../images/building.svg" alt="building">&nbsp;&nbsp;Building:</h5> 
											</div>
											<div class="col"> 
											<h5><a href="../../../show_building.php?id=1">gdhjghj</a></h5>
											</div>
										</div>
										<div class="row m-3">
											<div class="col"> 
											<h5><img src="../../../../../../images/room.png" width="18" alt="Room">&nbsp;&nbsp;Room:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../show_room.php?id=2">Luke Urtnowski</a></h5>
											</div>								 
										</div>
										<div class="row m-3">
											<div class="col"> 
											<h5><img src="../../../../../../images/rack.svg" width="18" alt="Rack">&nbsp;&nbsp;Rack:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../show_rack.php?id=2">gdfg</a></h5>
											</div>								 
										</div>							 
									</div>
									<div class="col">
									
									</div>
								</div>							 
							</div>
						    <div class="col border-start pt-3">
							  <h3 class="text-secondary ms-3">To</h3>
							  <hr>
								<div class="row">
									<div class="col">  
										<div class="row mb-3">
											<div class="col"> 
											<h5 class="ms-3"><span class="icon-map-marker"></span>&nbsp;&nbsp;&nbsp;Location:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../../../../show_location.php?id=1">gdfg</a></h5>
											</div>
										</div>
										<div class="row mb-3">
											<div class="col"> 
											<h5 class="ms-3"><span class="icon-bullseye"></span>&nbsp;&nbsp;Site:</h5>
											</div>
											<div class="col"> 
											<h5><a href="../../../../show_site.php?id=1">erd</a></h5>
											</div>
										</div>								
										<div class="row mb-3">
											<div class="col">
											  <h5 class="ms-3"><img src="../../../../../../images/building.svg" width="18" alt="building">&nbsp;&nbsp;Building:</h5>
											</div>
											<div class="col">
												<div class="input-group input-group-sm">
													<div class="input-group-prepend">
													  <span class="input-group-text text-secondary"><span class="icon-search"></span></span>
													</div>	
												  <select class="form-control" id="to_asset_building" name="to_asset_building" required>	
												  <option value='' disabled selected hidden>Select</option>
<option value='1'>gdhjghj</option>					
												  </select>
												</div>
											</div>
										</div>									
										<div class="row mb-3">
											<div class="col">
											  <h5 class="ms-3"><img src="../../../../../../images/room.png" width="18" alt='room'>&nbsp;&nbsp;Room:</h5>
											</div>
											<div class="col">
												<div class="input-group input-group-sm">
													<div class="input-group-prepend">
													  <span class="input-group-text text-secondary"><span class="icon-search"></span></span>
													</div>	
												  <select class="form-control" id="to_asset_room" name="to_asset_room">					
												  </select>
												</div>
											</div>
										</div>
										<div class="row mb-3">
											<div class="col">												  
											  <h5 class="ms-3"><img src="../../../../../../images/rack.svg" width="18" alt='rack'>&nbsp;&nbsp;Rack:</h5>
											</div>
											<div class="col">
												<div class="input-group input-group-sm">
													<div class="input-group-prepend">
													  <span class="input-group-text text-secondary"><span class="icon-search"></span></span>
													</div>	
												  <select class="form-control" id="to_asset_rack" name="to_asset_rack">	
												  </select>
												</div>
											</div>
										</div>
										<div class="row mb-3">
											<div class="d-grid">
												<button class="btn btn-outline-dark btn-lg" type="submit"><span class="icon-ok"></span>&nbsp;&nbsp;Submit</button>
											</div>
										</div>				
										<input type="hidden" value="1" name="asset_id">
										</form>
									</div>
									<div class="col">

			
									</div>							 
								</div>
					   
						   </div>
					    </div>
					</div>
				</div>
			</div>
		 </div>
    </div>
</div>
<script>
	document.getElementById('to_asset_building').addEventListener('change',postRooms);

function postRooms(e){
  e.preventDefault();

  var xhr = new XMLHttpRequest();
  xhr.open('POST', 'roomOptions.php');
  xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

  xhr.onload = function(){
	document.getElementById('to_asset_room').innerHTML = this.responseText;
  }
  xhr.send("building_id="+document.getElementById('to_asset_building').value);

}
	document.getElementById('to_asset_room').addEventListener('change',postRacks);

function postRacks(e){
  e.preventDefault();

  var xhr = new XMLHttpRequest();
  xhr.open('POST', 'rackOptions.php');
  xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

  xhr.onload = function(){
	document.getElementById('to_asset_rack').innerHTML = this.responseText;
  }
  xhr.send("room_id="+document.getElementById('to_asset_room').value);

}
	document.getElementById('to_asset_rack').addEventListener('change',postAssets);

function postAssets(e){
  e.preventDefault();

  var xhr = new XMLHttpRequest();
  xhr.open('POST', 'asset_options.php');
  xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

  xhr.onload = function(){
	document.getElementById('to_asset_id').innerHTML = this.responseText;
  }

  xhr.send("rack_id="+document.getElementById('to_asset_rack').value);

}

</script>
</body>
</html>

It looks as though it’s this

I see nothing except this statement and much code. The title is a question and my experience is that when the question is entirely in the title the question needs clarification. The question is very vague.

I see the code that Gandalf identified in the code twice. Note that there are other loops too.

That appears 3 times. That is a loop too, internally.

The question in the title says this. Which loop are you asking about?

So it does. It’s the second one that’s causing the problem.

[aside] I’m sure it’s been mentioned before that you should be using prepared statements.

1 Like

And hashed passwords.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.