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

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

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


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

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

													$id=$row['id'];
													$title=$row['title'];
													$description=$row['description'];
												  $gender=$row['gender'];
													$amount=$row['amount'];
													$bed_space=$row['bed_space'];
													$date_added=$row['date_added'];
													$block_status=$row['reserved'];



												}
											}
									}



}



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

				<input id="faculty_id" name="block_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'];
																					$title=$row['title'];
																					$campus_status=$row['status'];

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

																				}
																				echo $output;
																			}
													?>

																									</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="<?=$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="location" class="col-sm-3 col-form-label text-right">Gender
		 				</label>
		 					<div class="col-sm-9">
		 						<select class="form-control required" name="gender">
		               <option value="">----select ----</option>
		               <option value="male">Male</option>
		               <option value="female">Female</option>
		             </select>
		 					</div>
		              </div>

		 			 <div class="form-group row">
		 				<label for="Phone Number" class="col-sm-3 col-form-label text-right">Amount
		 				</label>
		 					<div class="col-sm-9">
		 						<input id="text" name="amount" type="text"
		 						placeholder="Amount " value="<?=$amount;?>" 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>
