<?php
if(isset($_POST['token'])){

		include_once('../../../db_connect/db.php');
		$room_id = $_POST["token"];

		$sqlmg=mysqli_query($conn_1, "SELECT hostel_rooms.id AS id ,hostel_rooms.title AS title, hostel_rooms.description AS description,
		hostel_rooms.bed_space AS bed_space, hostel_campuses.title AS campus, hostel_blocks.title AS block,
		hostel_rooms.date_added as date_added, hostel_rooms.status AS status, hostel_rooms.block_id,
		hostel_rooms.reserved AS reserved, hostel_rooms.campus_id FROM
		hostel_campuses,hostel_rooms, hostel_blocks WHERE hostel_rooms.campus_id= hostel_campuses.id AND
		 hostel_rooms.block_id= hostel_blocks.id
		AND  hostel_rooms.id='$room_id' ") or die(mysqli_error($conn_1));


									if($sqlmg){
										$sqlmg_row=mysqli_num_rows($sqlmg);
											if($sqlmg_row >0){

												while($row=mysqli_fetch_assoc($sqlmg)){

													$id=$row['id'];
													$room_title=$row['title'];
													$description=$row['description'];
													$date_added=$row['date_added'];
													$bed_space=$row['bed_space'];
													$campus=$row['campus'];
													$block=$row['block'];
													$Block_status = $row['reserved'];


												}
											}
									}



}



?>
<form method="POST" id="edit_form_faculty" >

				<input id="faculty_id" name="room_id" type="hidden" class="form-control required" value="<?=$id;?>" required />
				<div class="form-group row">
			<label for="category" class="col-sm-3 col-form-label text-right">Campus *</label>
																							<div class="col-sm-9">
																									<select class="form-control select21" id="school"
																													title="Select School..." name="campus_id">
																											<option disabled selected>Select Campus</option>
													<?php
													$select="SELECT * FROM hostel_campuses WHERE status ='1'";
																			$sql_select=mysqli_query($conn_1,$select);
																			$num_rows=mysqli_num_rows($sql_select);
																			if($num_rows > 0){

																				while($row=mysqli_fetch_array($sql_select)){
																					$campus_id=$row['id'];
																					$campus_title=$row['title'];
																					$campus_status=$row['status'];

																					 $output.='<option value="'.$campus_id.'">'.$campus_title.'</option>';

																				}
																				echo $output;
																			}
													?>

																									</select>
																							</div>
										</div>


										<div class="form-group row">
									<label for="category" class="col-sm-3 col-form-label text-right">Block *</label>
																													<div class="col-sm-9">
																															<select class="form-control select21" id="school"
																																			title="Select School..." name="block_id">
																																	<option disabled selected>Select Block</option>
																			<?php
																			$select="SELECT * FROM hostel_blocks WHERE status ='1'";
																									$sql_select=mysqli_query($conn_1,$select);
																									$num_rows=mysqli_num_rows($sql_select);
																									if($num_rows > 0){

																										while($rrow=mysqli_fetch_array($sql_select)){
																											$block_id=$rrow['id'];
																											$title=$rrow['title'];
																											$descripion=$rrow['description'];
																											$name = $title.'( '.$descripion.')';
																											$block_status=$rrow['status'];

																											 $outputs.='<option value="'.$block_id.'">'.$name.'</option>';

																										}

																									}
																									echo $outputs;
																			?>

																															</select>
																													</div>
																</div>
				<div class="form-group row">
				<label for="title" class="col-sm-3 col-form-label text-right">Title : (*)
				</label>
					<div class="col-sm-9">
						<input id="title" name="title" type="text"
						placeholder="Title " class="form-control required" value="<?=$room_title;?>" required />
					</div>
             </div>
						 <div class="form-group row">
	 										<label class="col-sm-3 col-form-label text-right"> Description</label>
	 							<div class="col-sm-9">
	 								<textarea class="form-control" rows="2" name="description" id="comment"><?=$description;?></textarea>
	 							</div>
	 					</div>
						<div class="form-group row">
		 				<label for="email" class="col-sm-3 col-form-label text-right">Bed Space
		 				</label>
		 					<div class="col-sm-9">
		 						<input id="bedspace" name="bedspace" type="text"
		 						placeholder="Bed Space " value="<?=$bed_space;?>" class="form-control required" />
		 					</div>
		              </div>






							<div class="form-group row">
 						 <label for="Phone Number" class="col-sm-3 col-form-label text-right">Status
 						 </label>
 							 <div class="col-sm-9">
 								 <select class="form-control required" name="status" id="status">
 										<option value="">-----Select ----</option>
 										<option value="0">Reserved</option>
 										<option value="1">Active</option>
 										<option value="1">Block</option>

 									</select>
 							 </div>
 									 </div>




						<div id="button_edit">
							<center>
														<button class="button button-3d button-primary button-rounded btn_3d" type="submit">Update
												</button>
						</div>
             </form>

			 <center>
				<div id="output_error_edit">

				</div>
			</center>
