I want to disable the checkboxes selected by user1 so that if another user logins the page he should not able to make any changes on the selectedcheckboxes.It is somewhat like restaurant table booking system
<?php
$st = "select * from seat where hotel='$test'";
$q= mysqli_query($conn,$st);
$tester = mysqli_fetch_array($q);
$tab = $tester['two'];
?>
<form method="post">
<input type="submit" name="bookbtn" value="Book Your table">
<div id="mask2"style="float:left;width:20%;">
<?php $i=1;
while ($i<=$tab)
{?>
<div class="TWO">
<div class="check"style="height:40px;width:120px;">
<div class="seconda">
</div>
<div class="secondb">
<input type ="checkbox"name="checky[]"
style="width:30px;height:30px;"
value="<?php echo "two".$i;?>"
<?php if (in_array("two".$i, $expcheck)) {?>
checked="checked"<?php }else {echo "none";}?>>
</div>
<div class="secondc">
</div>
</div>
</div>
After you have determined that it has been selected:
document.getElementByID('yourcheckboxID').setAttribute("disabled", "true");
just written disabled and it works
<form method="post">
<input type="submit" name="bookbtn" value="Book Your table">
<div id="mask2"style="float:left;width:20%;">
<?php $i=1;
while ($i<=$tab)
{?>
<div class="TWO">
<div class="check"style="height:40px;width:120px;">
<div class="seconda">
</div>
<div class="secondb">
<input type ="checkbox"name="checky[]"
style="width:30px;height:30px;"
value="<?php echo "two".$i;?>"
<?php if (in_array("two".$i, $expcheck)) {?>
checked="checked"<?php }else {echo "none";}?>disabled>
</div>
<div class="secondc">
</div>
</div>
</div>
Related
I want to load a php code in a page called index (parent page). The problem occurs when you press the filter button because the page does not load correctly (it also loads the parent page) and it does not show me the selected data from the form that I will want to query in the database.
The index page have the code:
<div class="row">
<div class="col-12">
<div class="card">
<div class="row mt-3">
<div class="col-md-1"></div>
<div class="col-md-4">
<select name="class" id="class_id" class="form-control select2" data-toggle = "select2" required>
<option value=""><?php echo get_phrase('select_a_class');?></option>
<?php
$classes = $this->db->get('classes')->result_array();
foreach($classes as $row):
?>
<option value="<?php echo $row['id'];?>"
<?php if ($class_id == $row['id']) echo 'selected';?>>
<?php echo $row['name'];?>
</option>
<?php
endforeach;
?>
</select>
</div>
<div class="col-md-4">
<select name="exam" id="exam_id" class="form-control select2" data-toggle = "select2" required>
<option value=""><?php echo get_phrase('select_a_exam');?></option>
<?php
$exams = $this->db->get_where('exams' , array('session' => active_session()))->result_array();
foreach($exams as $row):
?>
<option value="<?php echo $row['id'];?>"
<?php if ($exam_id == $row['id']) echo 'selected';?>>
<?php echo $row['name'];?>
</option>
<?php
endforeach;
?>
</select>
</div>
<div class="col-md-2">
<button class="btn btn-block btn-secondary" onclick="filter()" ><?php echo get_phrase('filter'); ?></button>
</div>
</div>
<div class="card-body tabulation_content">
<div class="empty_box">
<img class="mb-3" width="150px" src="<?php echo base_url('assets/backend/images/empty_box.png'); ?>" />
<br>
<span class=""><?php echo get_phrase('no_data_found'); ?></span>
</div>
</div>
</div>
</div>
</div>
The list page that i want to load
<div class="row">
<div class="col-md-12">
<table class="table table-bordered">
<thead>
<tr>
<td ><?php echo $exam_id?></td>
<td ><?php echo $class_id?></td>
<td >333</td>
</tr>
</thead>
</table>
</div>
</div>
The JavaScript filter
<script>
$('document').ready(function(){
initSelect2(['#class_id', '#exam_id']);
});
function filter(){
var exam = $('#exam_id').val();
var class_id = $('#class_id').val();
if(class_id != "" && exam != "" ){
$.ajax({
type: 'POST',
url: '<?php echo route('tubulation/list/') ?>',
data: {class_id : class_id, exam : exam},
success: function(response){
$('.tabulation_content').html(response);
}
});
}else{
toastr.error('<?php echo get_phrase('please_select_in_all_fields !'); ?>');
}
}
</script>
[You can see the result here on this picture]
I want to show Package Categories with JSON. I have 2 Tables. First one is Package Table, second one is packageService. First table is Package Table. I get all data from Package Table. Each Package has own features(services). I show this features Package below on Package View. I want to get all features(services) from packageServices. But I want to get this features by packageServiceId from packageService table with JSON such as [1][2] etc. In Package Table has a column as packageService equal packageServiceId on packageService Table. How can I write data from post form on Edit Page to Package Table with JSON?
Controller of Package:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Package extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('service_model');
}
public function index()
{
$this->lang->load('content', $this->session->userdata('userLang'));
//$viewData['packs'] = $this->db->get("package")->result();
$this->db->order_by('packageId','DESC');
$viewData['packs_P'] = $this->db->get_where('package',array('packageNameEn'=> 'Platinum'),1)->result();
$this->db->order_by('packageId','DESC');
$viewData['packs_S'] = $this->db->get_where('package',array('packageNameEn'=> 'Silver'),1)->result();
$this->db->order_by('packageId','DESC');
$viewData['packs_G'] = $this->db->get_where('package',array('packageNameEn'=> 'Gold'),1)->result();
$this->db->order_by('packageId','DESC');
$package_n = $this->input->post('packageNameEn');
$viewData['packs'] = $this->db->get_where('package',array('packageNameEn'=> $package_n),1)->result();
$this->load->view('package', $viewData);
}
public function edit($packageId)
{
$this->lang->load('content', $this->session->userdata('userLang'));
$viewData['packages'] = $this->db->where("packageId", $packageId)->get("package")->result();
$viewData['packs'] = $this->db->get("package")->result();
$this->load->view('package_edit', $viewData);
}
public function update($packageId) {
$this->lang->load('content', $this->session->userdata('people_lang'));
$data = array (
"packageEditUser" => $this->input->post("packageEditUser"),
"packageRev" => $packageId,
"packageNameEn" => $this->input->post("packageNameEn"),
"packagePrice" => $this->input->post("packagePrice"),
"packagePriceCut" => $this->input->post("packagePriceCut"),
"packageActive" => $this->input->post("packageActive"),
"packageEditDate" => date('Y-m-d H:i:s'),
);
$update = $this->db->insert("package", $data);
$viewData['services'] = $this->service_model->update_services($packageId);
$this->load->view('package',$viewData);
if($update) {
redirect(base_url("package"));
}else {
echo "Hata!";
}
}
public function add()
{
$this->lang->load('content', $this->session->userdata('userLang'));
$viewData['packages'] = $this->db->get("package")->result();
$this->load->view('package_add', $viewData);
}
public function insert() {
$this->lang->load('content', $this->session->userdata('people_lang'));
$this->load->view('package');
$data = array (
"packageAddUser" => $this->input->post("packageAddUser"),
"packageNameEn" => $this->input->post("packageNameEn"),
"packagePrice" => $this->input->post("packagePrice"),
"packagePriceCut" => $this->input->post("packagePriceCut"),
"packageActive" => $this->input->post("packageActive"),
"packageAddDate" => date('Y-m-d H:i:s'),
"packageEditDate" => date('Y-m-d H:i:s'),
"packageRev" => '0'
);
$insert = $this->db->insert("package", $data);
if($insert) {
redirect(base_url("package"));
}else {
echo "Hata!";
}
}
}
?>
Package View:
<section id="main-content">
<section class="wrapper site-min-height">
<!-- page start-->
<div class="row">
<!--price start-->
<div class="text-center feature-head">
<h1> PACKAGES </h1>
<p>Choose Your Special Package Plan. </p>
</div>
<?php foreach($packs_S as $get) { ?>
<div class="col-lg-3 col-sm-3">
<div class="pricing-table <?php if ($get->packageNameEn == 'Platinum') { echo 'most-popular'; } ?>">
<div class="pricing-head">
<h1> <?php echo $get->packageNameEn; ?> </h1>
<h5><del>€ <?php echo $get->packagePrice ?></del></h5>
<h2><span class="note">€</span><?php echo $get->packagePriceCut ?> </h2>
</div>
//json data will write here:
<ul class="list-unstyled">
<li>8 hours coverage</li>
<li>500 digital images</li>
<li>100 A3 Hard Copy</li>
<li>Bridal portrait with 11X14</li>
<li>Engagement portrait with 11X14</li>
<li>Income Tax included</li>
</ul>
//json data will write here/
<div class="price-actions">
<a class="btn" href="javascript:;">Get Now</a>
<a class="btn" href="<?php echo base_url("package/edit/$get->packageId"); ?>">Edit</a>
</div>
</div>
</div>
<?php } ?>
<?php foreach($packs_G as $get) { ?>
<div class="col-lg-3 col-sm-3">
<div class="pricing-table <?php if ($get->packageNameEn == 'Platinum') { echo 'most-popular'; } ?>">
<div class="pricing-head">
<h1> <?php echo $get->packageNameEn; ?> </h1>
<h5><del>€ <?php echo $get->packagePrice ?></del></h5>
<h2><span class="note">€</span><?php echo $get->packagePriceCut ?> </h2>
</div>
<ul class="list-unstyled">
<li>8 hours coverage</li>
<li>500 digital images</li>
<li>100 A3 Hard Copy</li>
<li>Bridal portrait with 11X14</li>
<li>Engagement portrait with 11X14</li>
<li>Income Tax included</li>
</ul>
<div class="price-actions">
<a class="btn" href="javascript:;">Get Now</a>
<a class="btn" href="<?php echo base_url("package/edit/$get->packageId"); ?>">Edit</a>
</div>
</div>
</div>
<?php } ?>
<?php foreach($packs_P as $get) { ?>
<div class="col-lg-3 col-sm-3">
<div class="pricing-table <?php if ($get->packageNameEn == 'Platinum') { echo 'most-popular'; } ?>">
<div class="pricing-head">
<h1> <?php echo $get->packageNameEn; ?> </h1>
<h5><del>€ <?php echo $get->packagePrice ?></del></h5>
<h2><span class="note">€</span><?php echo $get->packagePriceCut ?> </h2>
</div>
<ul class="list-unstyled">
<li>8 hours coverage</li>
<li>500 digital images</li>
<li>100 A3 Hard Copy</li>
<li>Bridal portrait with 11X14</li>
<li>Engagement portrait with 11X14</li>
<li>Income Tax included</li>
</ul>
<div class="price-actions">
<a class="btn" href="javascript:;">Get Now</a>
<a class="btn" href="<?php echo base_url("package/edit/$get->packageId"); ?>">Edit</a>
</div>
</div>
</div>
<?php } ?>
<?php foreach($packs as $get) { ?>
<div class="col-lg-3 col-sm-3">
<div class="pricing-table <?php if ($get->packageNameEn == 'Platinum') { echo 'most-popular'; } ?>">
<div class="pricing-head">
<h1> <?php echo $get->packageNameEn; ?> </h1>
<h5><del>€ <?php echo $get->packagePrice ?></del></h5>
<h2><span class="note">€</span><?php echo $get->packagePriceCut ?> </h2>
</div>
<ul class="list-unstyled">
<li>8 hours coverage</li>
<li>500 digital images</li>
<li>100 A3 Hard Copy</li>
<li>Bridal portrait with 11X14</li>
<li>Engagement portrait with 11X14</li>
<li>Income Tax included</li>
</ul>
<div class="price-actions">
<a class="btn" href="javascript:;">Get Now</a>
<a class="btn" href="<?php echo base_url("package/edit/$get->packageId"); ?>">Edit</a>
</div>
</div>
</div>
<?php } ?>
</div>
<!-- page end-->
</section>
</section>
<!--main content end-->
Package Edit View:
<form class="cmxform form-horizontal tasi-form" id="signupForm" enctype="multipart/form-data" method="post" action="<?php echo base_url("package/update/$get->packageId"); ?>">
<?php } ?>
<!-- Hidden Classes -->
<div class="form-group" hidden>
<label class="col-sm-2 col-sm-2 control-label">The User Who Edit</label>
<div class="col-sm-10">
<input type="text" name="packageEditUser" class="form-control" value="<?php echo $this->session->userdata('people_id'); ?>" readonly>
</div>
</div>
<div class="form-group" hidden>
<label class="col-sm-2 col-sm-2 control-label">Rev Id</label>
<div class="col-sm-10">
<?php foreach($packages as $get) { ?>
<input type="text" name="packageRev" class="form-control" value="<?php echo $get->packageId; ?>" readonly>
<?php } ?>
</div>
</div>
<!-- / Hidden Classes -->
<div class="form-group ">
<label for="username" class="control-label col-lg-2">Package Name: </label>
<div class="col-lg-10">
<?php foreach($packages as $get) { ?>
<input class=" form-control" type="text" value="<?php echo $get->packageNameEn; ?>" readonly />
<?php } ?>
</div>
</div>
<!-- Basic select -->
<div class="form-group">
<label class="control-label col-lg-3">Package Name <span class="text-danger">*</span></label>
<div class="col-lg-9">
<?php foreach($packages as $get) { ?>
<input type="text" name="packageNameEn" class="form-control" placeholder="Package Name" value="<?php echo $get->packageNameEn; ?>">
<?php }?>
</div>
</div>
<!-- /basic select -->
<div class="form-group">
<label class="col-sm-2 control-label col-lg-2" for="inputSuccess">Services:</label>
<div class="col-lg-6">
<div class="checkboxes">
<label class="label_check" for="checkbox-01">
<input name="sample-checkbox-01" id="checkbox-01" value="1" type="checkbox" /> I agree to the terms & conditions.
</label>
<label class="label_check" for="checkbox-02">
<input name="sample-checkbox-02" id="checkbox-02" value="1" type="checkbox" /> Please send me regular updates. </label>
<label class="label_check" for="checkbox-03">
<input name="sample-checkbox-02" id="checkbox-03" value="1" type="checkbox" /> This is nice checkbox.</label>
<label class="label_check" for="checkbox-04">
<input name="sample-checkbox-04" id="checkbox-04" value="1" type="checkbox" /> I agree to the terms & conditions.
</label>
<label class="label_check" for="checkbox-05">
<input name="sample-checkbox-05" id="checkbox-05" value="1" type="checkbox" /> Please send me regular updates. </label>
<label class="label_check" for="checkbox-06">
<input name="sample-checkbox-06" id="checkbox-06" value="1" type="checkbox" /> This is nice checkbox.</label>
<label class="label_check" for="checkbox-07">
<input name="sample-checkbox-07" id="checkbox-07" value="1" type="checkbox" /> I agree to the terms & conditions.
</label>
<label class="label_check" for="checkbox-08">
<input name="sample-checkbox-08" id="checkbox-08" value="1" type="checkbox" /> Please send me regular updates. </label>
<label class="label_check" for="checkbox-09">
<input name="sample-checkbox-09" id="checkbox-09" value="1" type="checkbox" /> This is nice checkbox.</label>
<label class="label_check" for="checkbox-10">
<input name="sample-checkbox-10" id="checkbox-10" value="1" type="checkbox" /> This is nice checkbox.</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-6">
<h5>Package Price:</h5>
<div class="input-group m-bot15">
<span class="input-group-addon"><i class="fas fa-euro"></i></span>
<?php foreach($packages as $get) { ?>
<input type="text" name="packagePrice" data-mask="€ 999.99" class="form-control" value="<?php echo $get->packagePrice; ?>">
<?php }?>
</div>
</div>
<div class="col-lg-6">
<h5>Discounted Price:</h5>
<div class="input-group m-bot15">
<span class="input-group-addon"><i class="fas fa-euro"></i></span>
<?php foreach($packages as $get) { ?>
<input type="text" name="packagePriceCut" data-mask="€ 999.99" class="form-control" value="<?php echo $get->packagePriceCut; ?>">
<?php }?>
</div>
</div>
</div>
<!-- Basic select -->
<div class="form-group">
<label class="control-label col-lg-3">Status <span class="text-danger">*</span></label>
<div class="col-lg-9">
<select name="packageActive" class="form-control">
<?php foreach($packages as $get) { ?>
<option value="<?php echo $get->packageActive; ?>" readonly><?php if($get->packageActive == 1) {echo 'Active';} else {echo 'Deactive';} ?></option>
<?php }?>
<option value="1">Active</option>
<option value="2">Deactive</option>
</select>
</div>
</div>
<!-- /basic select -->
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button class="btn btn-success" type="submit">Edit Package</button>
<button class="btn btn-default" type="reset">Reset</button>
</div>
</div>
</form>
In codeingitor, you can get table data in form of JSON like this example
In model
function function_table_name(){
$query = $this->db->get('table_name');
return $query->result();
}
In Controller
public function employees()
{
$data = array();
$data = $this->model_name->function_table_name();
echo json_encode($data);
// echo '<pre>';
// print_r($data);
}
If you want to load this in view you can do like this.
Controller.php
$data = array();
$data['myJson'] = json_decode(file_get_contents('some_url'));
$this->load->view('my_view',$data);
view.php
<?php
//Access them like so
print_r($myJson);
// Rest of your code here to play with json
?>
</html>
New:
the changing the id and name works, but what if there are more inputs? the codepen only has one, but the real project would have several ie component_date, component_owner, how do I set these input unique as well?
I have this form that has a portion of it that replicates. The part that replicates has several inputs that need to be unique. Currently when replicated the name and id change, I would like to keep the existing name and
id and just add on a incremented number. Currently the inputs that are replicable change. so that initially, name="component_name" and id ="input-name when replicated the new inputs have name componentName_0 componentID_0. I want the initial input to have _0 and then each replicated one have the next increment. so component 2 would have name="component_1 id="input-name_1 and so on.
Essentially I want to use the original component id and name but just add an incremented number to each. in addition it would be nice to have the inital have a number(0?) already affixed to it. currently when replicated the name and id change from what they are initially
here is a simplified codepen to show what I mean:
https://codepen.io/anon_guy/pen/VMZWWW?editors=1010
HTML:
<div class="wrapper">
<div class="panel panel-default" id="add-components">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-pencil"></i> <?php echo $text_add_component; ?></h3>
</div>
<div class="panel-body" id="addon">
<div class="tab-content">
<div class="tab-pane active" id="tab-general">
<?php foreach ($languages as $language) { ?>
<div class="tab-pane" id="language<?php echo $language['language_id']; ?>">
<div class="form-group required">
<div class= "row">
<div class="col-sm-8 col-sm-push-1 form-group required" >
<label for="input-name<?php echo $language['language_id']; ?>"><?php echo $entry_name; ?></label>
<input type="text" name="component_name" placeholder="<?php echo $entry_name; ?>" id="input-name<?php echo $language['language_id']; ?>" class="form-control" value="<?php echo $component_name; ?>" />
<?php if (isset($error_name[$language['language_id']])) { ?>
<div class="text-danger"><?php echo $error_name[$language['language_id']]; ?></div>
<?php } ?>
</div>
<div class="col-sm-2 col-sm-push-1 form-group required">
<div class="campaign-group form-group">
<div class="dropdown">
<button class="btn btn-primary pull-left dropdown-toggle" type="button" id="button-type" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"><?php echo $text_filter_type;?><span class="caret"></span></button>
<ul class="campaign-form-type dropdown-menu">
<li class="campaign-dropdown-list">Direct Mail</li>
<li class="campaign-dropdown-list">Email</li>
<li class="campaign-dropdown-list">Event</li>
<li class="campaign-dropdown-list">Text Message</li>
<li class="campaign-dropdown-list">Letter</li>
<li class="campaign-dropdown-list">Postcard</li>
</ul>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-4 col-sm-push-1 form-group required">
<label class="control-label" for="input-date-beginning"><?php echo $entry_campaign_start_date; ?></label>
<div class="input-group date required">
<input type="text" name="component_date" placeholder="<?php echo $entry_date; ?>" data-date-format="YYYY-MM-DD" id="input-component_date" class="form-control" />
<span class="input-group-btn">
<button class="btn btn-default" type="button"><i class="fa fa-calendar"></i></button>
</span>
</div>
<?php if (isset($error_date_starting)) { ?>
<label class="text-danger"><?php echo $error_date_starting; ?></label>
<?php } ?>
</div>
<div class="col-sm-4 col-sm-push-1 form-group required">
<label class="control-label" ><?php echo $entry_owner; ?></label>
<select name="component_owner" id="component_owner">
<?php foreach ($users as $user) { ?>
<option value="<?php echo $user['username']; ?>"><?php echo $user['username']; ?></option>
<?php } ?>
</select>
</div>
<div class="col-sm-5 col-sm-push-1 form-group required">
<!--label class="control-label" for="input-code"><?php echo $entry_code; ?></label-->
<div class="input-code required">
<input type="text" name="campaign_code" value="<?php echo $code; ?>" placeholder="<?php echo $code; ?>" id="input-campaign_code" class="form-control" readonly />
</div>
<?php if (isset($error_date_starting)) { ?>
<label class="text-danger"><?php echo $error_code; ?></label>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
</form>
</div>
</div>
JS:
<script type="text/javascript">
let cloneList = [];
var i = 0;
document.getElementById('launch').onclick = function(event) {
event.preventDefault();
var addOnDiv = document.getElementById('addon');
var container = document.getElementById('add-components')
var clonedNode = addOnDiv.cloneNode(true);
var component = clonedNode.querySelector('input');
clonedNode.id = i++;
cloneList.push(clonedNode.id);
component.id = `componentID_${clonedNode.id}`;
component.name = `componentName_${clonedNode.id}`;
container.appendChild(clonedNode);
}
</script>
It looks like you figured it out. appendChild was misspelled in your CodePen, I believe. As for the initial component having id 0, you could change the name and ID of the component to componentID_0 in your HTML, and then set var i = 1.
Use a loop on php, keep track of the counter, and concatenate the counter with the name or id.
E.g
for($i=0; $i<5; $i++){
echo '<div id="myID_"' . $i . 'andSoOn>'
}
I am using Laravel, I have a following data view
<div class="content-inside-main">
<div class="content-inside" id="content-inside-feedback">
<div class="row header-content space-div">
<div class="col-lg-1"><h5>#</h5></div>
<div class="col-lg-1"><h5>Member Id</h5></div>
<div class="col-lg-4"><h5>Question</h5></div>
<div class="col-lg-4"><h5>Reply</h5></div>
<div class="col-lg-1"><h5>Replied by</h5></div>
<div class="col-lg-1"><h5>Options</h5></div>
</div>
<div>
<hr class="line-div"/>
</div>
<?php
$questions= \App\Question::all();
?>
<?php
foreach ($questions as $question):
$id = $question->id;
$member_id = $question->user_id;
$body = $question->message;
$status=$question->replied;
$reply=$question->reply;
$user_id=$question->replied_id;
$member=\App\Member::find($member_id);
$m_id=$member->id;
$m_name=$member->nick_name;
$m_reg_time=$member->reg_time;
$m_unreg_time=$member->unreg_time;
$m_status=$member->unreg;
$m_group_id=$member->group;
$group=\App\Group::find($m_group_id);
$m_group_name=$group->name;
if($id != NULL) {
?>
<div class="row content-messages" >
<input type="hidden" id="count" value="{{$id}}"/>
<div class="col-lg-1"><?php echo $id; ?></div>
<div class="col-lg-1"><?php echo $member_id; ?></div>
<div class="col-lg-4"><?php echo $body; ?></div>
<div class="col-lg-4">
<?php
if($status == 0){
?>
<div class="according-form-container" id="reply-feedback-form_<?php echo $id; ?>">
<a class="btn-link show-add-form-div" data-toggle="collapse" data-parent="#reply-feedback-form_<?php echo $id; ?>" href="#reply-feedback-form_content_<?php echo $id; ?>" >
Reply
</a>
<div id="reply-feedback-form_content_<?php echo $id; ?>" class="collapse collapse-add-form">
<form class="form" id="reply-feedback_<?php echo $id; ?>" enctype="multipart/form-data" method="post" action="addreply">
{{csrf_field()}}
<div class="control-group">
<label class="control-label" for="description">Message: </label>
<div class="controls">
<input type="hidden" name="id" id="id" value="{{$id}}"/>
<input type="hidden" name="member_id" id="member_id" value="{{$member_id}}"/>
<input type="hidden" name="user_id" id="user_id" value="{{Auth::id()}}"/>
<textarea name="description" id="feedback-message_<?php echo $id; ?>" class="input-block-level" required></textarea>
<br/><br/>
<button id="submitfeedback_<?php echo $id . '_' . $member_id; ?>" type="submit" class="btn feedback-reply-submit-btn">Send</button>
</div>
</div>
</form>
<div id='preview_feedback_<?php echo $id; ?>'>
</div>
</div>
</div>
<?php
} else {?>
<div class="col-lg-4">{{$reply}}</div>
<?php
}
?>
</div>
<div class="col-lg-1">
<?php
if($user_id != null){
$user_name= DB::table('admin')->where('id',$user_id)->value('name');
echo $user_name;
}else {
echo 'None';
}
?>
</div>
<div class="col-lg-1">
<button id="view_member" name="view_member" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#view_memeber"
>View
</button>
</div>
</div>
<hr class="line-div" />
<?php
}
endforeach;
?>
<div id="show"></div>
<div class="text-center navigation-paginator" id="paginator" >
</div>
</div>
I have another application.It fill question table anytime.I want to do If question table have new records,show them in this page without refreshing.
Like following screenshots:
before
after
You could send periodical ajax calls and then compare the results with the data you already have to add the new values. It could be something along this lines:
function query() {
$.ajax({
url: 'your/url',
success: function(data) {
var loadedValues = JSON.parse(data).values;
// Iterate only in the new values
for(i = existingValues.length; i < loadedValues.length; i++) {
$("#content-inside-feedback").append(/*HTML you want to add*/);
}
}
});
setTimeout(executeQuery, 5000);
}
$(document).ready(function() {
// First call, then it will be called periodically
setTimeout(query, 5000);
});
I've some code I've been working on, which uses AJAX to generate a second dropdown based on information in the database.
For example
If you select BMW
it will populate the second list with all available BMW models, this is working correctly, but I would like one of the fields in the second drop down to remain SELECT, or ANY, so that they can search solely on car Make.
I've had a look online and the solutions seem very complicated for what I would hoped was a simple fix, I'm now stuck on how to fix the issue, should I just add a separate form for just make? Although this wouldn't be as user friendly.
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<form id="fitment_search" action="gallery.php" method="GET">
<div class="col-sm-5">
<div class="col-sm-4">
<h5>Vehicle Make:</h5>
</div>
<div class="col-sm-8">
<div class="select">
<select name="make" onchange="get_model(this.value)">
<option value="make">SELECT</option>
<?php while ($row = mysqli_fetch_assoc($makeResult)) : ?>
<option
value="<?php echo $row['make']; ?>"><?php echo $row['make']; ?></option>
<?php endwhile; ?>
</select>
<div class="select__arrow"></div>
</div>
</div>
</div>
<div class="col-sm-5">
<div class="col-sm-4">
<h5>Model:</h5>
</div>
<div class="col-sm-8">
<div class="select">
<select name="model" id="fitment_model">
<option value="">SELECT</option>
</select>
<div class="select__arrow"></div>
</div>
</div>
</div>
<div class="col-sm-2">
<button type="submit" class="btn btn-default btn-sm btn-primary"><i
class="fa fa-pencil"></i> Search Now
</button>
</div>
</form>
</div>
Heres the code form the seperate php file.
$make=$_GET["make"];
$sql2 = "SELECT `model` FROM `fitment` WHERE `make` = '$make' ORDER BY `model` ASC";
$result = mysqli_query($db, $sql2);
?>
<select name="models"> <?php
while($row = mysqli_fetch_array($result)) { ?>
<option value="<?php echo $row['model']?>"><?php echo $row['model'] ?></option><?php
} ?>
</select>
just change:
<select name="models"> <?php
TO
<select name="models">
<option value="" >Select</option>
<?php