Я хочу сделать бронирование PG, у меня есть одно поле формы в этом поле (index.php). Я выбираю разделение комнаты, как 1 совместное использование или 2 обмена и т. Д. После выбора этого pg sharing i передал значение на следующей странице (pg_deatils.php) через AJAX, и я выбираю из DB, в котором есть 1 общий доступ или 2 обмена после того, как я вернул значение в index.php, но я получаю правильный после этого, я хочу добавить значение в html, введите номер 1, Romm 2 ... я хочу добавить значение console.log (value.pg_id); // 2,1 и установить Bed 1, Bed1 ... я хочу добавить консоль. журнал (value.room_number); // room1, room2Как добавить значение в forloop и jquery HTML
function showDiv(toggle){
var sharing=$("#sharing").val();
$.ajax({
type: "POST",
url: "pg_details.php",
data: "sharing_id="+sharing,
success: function(data) {
var res =jQuery.parseJSON(data);
console.log(res);
if(res['return'] == 1){
var htmlString='';
$.each(res['data'], function(key, value){
console.log(value.pg_id);// 2,1
console.log(value.room_number);//room1,room2
});
}
}
});
}
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<h3 style="text-align:center;color:white; margin-top:70px;padding-bottom:30px;">PG Booking System</h3>
<form class="form-horizontal" > \t \t \t \t \t \t \t
<div class="form-group">
<label class="control-label col-sm-2" for="phone">Sharing:</label>
<div class="col-sm-10">
<select class="form-control" name="sharing" id="sharing">
<option value="">---select---</option>
</select>
</div>
</div>
<div class="form-group" style="margin-top:30px;">
<div class="col-sm-offset-5 col-sm-8">
<button type="button" class="btn btn-primary" name="answer" onclick="showDiv('toggle')" style=" margin-top:50px;margin-bottom:50px;">Submit</button>
</div>
</div>
</form>
</div>
<div class="col-md-3"></div>
</div> \t
<!--This HTML i want to append-->
<div id="toggle" style="display:none">
<div class="container" style=" margin-bottom: 30px;">
<div class="row">
<h4 style="margin-left:15px;">PG NAME 1</h4>
<div class="col-sm-10">
<div class="btn-group" id="btnmar">
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px; ">Bed 1</button>
</a>
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px;">Bed 2</button>
</a>
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px; ">Bed 3</button>
</a>
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px; ">Bed 4</button>
</a>
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px;">Bed 5</button>
</a>
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px; ">Bed 6</button>
</a>
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px;">Bed 7</button>
</a>
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px;">Bed 8</button>
</a>
</div>
</div>
<!--hidden 6 end-->
<!--hidden 4 start-->
<div class="col-sm-2">
<div class="panel-group">
<div class="panel panel-primary">
<div class="panel-heading"> Premium Facility</div>
<div class="panel-body" style=" padding-top: 5px; padding-bottom: 5px;"><i class="fa fa-television" aria-hidden="true" style="margin-right:15px;"></i>T.V.</div>
<div class="panel-body" style=" padding-top: 5px; padding-bottom: 5px;"><i class="fa fa-wifi" aria-hidden="true" style="margin-right:15px;"></i>Wifi</div>
<div class="panel-body" style=" padding-top: 5px; padding-bottom: 5px;"><i class="fa fa-bed" aria-hidden="true" style="margin-right:15px;"></i>Bed</div>
<div class="panel-body" style=" padding-top: 5px; padding-bottom: 5px;"><i class="fa fa-shopping-basket" aria-hidden="true" style="margin-right:15px;"></i>Washing Machine</div>
</div>
</div>
</div>
<!--hidden 4 end-->
</div>
<!--row1 end-->
<!--row2 start-->
<div class="row">
<h4 style="margin-left:15px;">PG NAME 2</h4>
<div class="col-sm-10">
<div class="btn-group" id="btnmar">
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px;">Bed 1</button>
</a>
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px;">Bed 2</button>
</a>
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px;">Bed 3</button>
</a>
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px;">Bed 4</button>
</a>
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px;">Bed 5</button>
</a>
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px;">Bed 6</button>
</a>
</div>
</div>
<!--hidden 6 end-->
<!--hidden 4 start-->
<div class="col-sm-2">
<div class="panel-group">
<div class="panel panel-primary">
<div class="panel-heading"> Classic Facility</div>
<div class="panel-body" style=" padding-top: 5px; padding-bottom: 5px;"><i class="fa fa-television" aria-hidden="true" style="margin-right:15px;"></i>T.V.</div>
<div class="panel-body" style=" padding-top: 5px; padding-bottom: 5px;"><i class="fa fa-wifi" aria-hidden="true" style="margin-right:15px;"></i>Wifi</div>
<div class="panel-body" style=" padding-top: 5px; padding-bottom: 5px;"><i class="fa fa-bed" aria-hidden="true" style="margin-right:15px;"></i>Bed</div>
<div class="panel-body" style=" padding-top: 5px; padding-bottom: 5px;"><i class="fa fa-shopping-basket" aria-hidden="true" style="margin-right:15px;"></i>Washing Machine</div>
</div>
</div>
</div>
<!--hidden 4 end-->
</div>
<!--row2 end-->
<!--row2 start-->
<div class="row">
<h4 style="margin-left:15px;">PG NAME 3</h4>
<div class="col-sm-10">
<div class="btn-group" id="btnmar">
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px;">Bed 1</button>
</a>
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px;">Bed 2</button>
</a>
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px;">Bed 3</button>
</a>
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px;">Bed 4</button>
</a>
<a href="register.php">
<button type="button" class="btn btn-primary" style=" width: 71px;">Bed 5</button>
</a>
</div>
</div>
<!--hidden 6 end-->
<!--hidden 4 start-->
<div class="col-sm-2">
<div class="panel-group">
<div class="panel panel-primary">
<div class="panel-heading"> Basic Facility</div>
<div class="panel-body" style=" padding-top: 5px; padding-bottom: 5px;"><i class="fa fa-television" aria-hidden="true" style="margin-right:15px;"></i>T.V.</div>
<div class="panel-body" style=" padding-top: 5px; padding-bottom: 5px;"><i class="fa fa-wifi" aria-hidden="true" style="margin-right:15px;"></i>Wifi</div>
<div class="panel-body" style=" padding-top: 5px; padding-bottom: 5px;"><i class="fa fa-bed" aria-hidden="true" style="margin-right:15px;"></i>Bed</div>
<div class="panel-body" style=" padding-top: 5px; padding-bottom: 5px;"><i class="fa fa-shopping-basket" aria-hidden="true" style="margin-right:15px;"></i>Washing Machine</div>
</div>
</div>
</div>
<!--hidden 4 end-->
</div>
<!--row3 end-->
</div>
</div>
pg_details.php
<?php
include_once("admin/config.php");
include("functions.php");
//$pg_name=Getpg($_POST['pg_id']);
$sharing=$_POST['sharing_id'];//Getting Sharing Value
$sql=mysql_query("SELECT * FROM rooms WHERE room_sharing='$sharing'");
$count = mysql_num_rows($sql);
if($count > 0){
while($row=mysql_fetch_assoc($sql)){
$data[]= $row;
}
$pg_type= array("return"=>1,"count" =>$count,"data" =>$data);
echo $pg_type = json_encode($pg_type);
}else{
$pg_type= array("return"=>0,"count" =>0,"data" =>"");
echo $pg_type = json_encode($pg_type);
}
?>