How to display buttons only when checked - php

I am working on an assignment. I need to display buttons using jquery only when the checkbox is checked and only for few subjects. All the subjects are coming from the backend using php and mysql. The table is getting subjects dynamically.
I want to display button or text only when few of the subjects are checked
Here is the code
<?php
if($stmt = $conn->prepare("SELECT classid, code, name, teacher, classroom,
time, cost FROM classes ORDER BY classid")){
// $stmt->bind_param("isssssd");
$result = $stmt->execute();
$stmt->bind_result($classid, $code, $name, $teacher, $classroom, $time,
$cost);
$checked = "";
while ($stmt->fetch()) {
$row = array("classid"=>$classid, "code"=>$code, "name"=>$name,
"teacher"=>$teacher, "classroom"=>$classroom, "time"=>$time, "cost"=>$cost);
if(in_array($classid, $selectedclasses)){
$checked = "checked";
}else{
$checked = "";
}
?>
<div class="row col-md-12">
<hr/>
</div>
<div class="row col-md-12" id="class_<?php echo $classid; ?>">
<div class="col-md-4 col-lg-4 col-sm-6 col-sx-6">
<input type="checkbox" id="classitem_<?php echo $classid; ?>"
name="classitem_<?php echo $classid; ?>" class="classitem" value="<?php echo
$classid; ?>" <?php echo $checked; ?> > <?php echo $name; ?>
</div>
<div class="col-md-2 col-lg-2 col-sm-6 col-sx-6">
<?php echo $teacher; ?>
</div>
<div class="col-md-2 col-lg-2 col-sm-6 col-sx-6">
<?php echo $cost; ?>
</div>
<div id="mine" class="col-md-4 col-lg-4 col-sm-6 col-sx-6">
<?php echo $time; ?>
</div>
</div>
<?php
}
$stmt->close();
}
?>

you need to try something like given below.
$(function()
{
$('[name="products_id"]').change(function()
{
if ($(this).is(':checked')) {
$("#demo").css('display', 'block');
}
else{
$("#demo").css('display', 'none');
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<button type="submit" id="demo" class="btn btn-success" name="export_all" style="display: none;">click</button>
<input class="form-check-input" type="checkbox" value="" id="defaultCheck1" name='products_id'>

Related

Foreach Loop in a view doesn't work in CI3 view

Hi I'm trying to do foreach loop on a view but it's not showing. I've checked the database and there's data. I've checked the QueryBuilder on the model and run the query on phpmyadmin and its working. Do you guys know what happened?
view:
<div class="content-wrapper">
<section class="content">
<div class="row">
<?php
foreach ($node as $d) {
?>
<div class="col-lg-6 col-md-6 col-xs-6">
<div class="box box-device box-solid" id="device_<?php echo $d['id_device']; ?>">
<div class="box-header">
<div class="row">
<div class="col-sm-3 col-xs-3">
<button aria-pressed="false" data-device="<?php echo $d['id_device']; ?>" class="btn btn-onoff btn-sm btn-toggle<?php echo ($d['status_device'] == 1) ? ' active': ''; ?>" data-toggle="button" type="button">
<div class="handle"></div>
</button>
</div>
<div class="col-sm-9 col-xs-9">
<h3 class="box-title<?php echo ($d['rule'] == 0) ? ' notactive': ''; ?>"><?php echo $d['nama_device']; ?></h3>
</div>
</div>
</div>
<div class="box-body text-center" onclick="window.location.href = '<?php echo site_url('Setting/rule/' . $d['id_device']); ?>'">
<img alt="<?php echo $d['nama_device']; ?>" src="<?php echo base_url('uploads/device/' . $d['foto']); ?>" />
<h4><?php echo $d['nama_device']; ?></h4>
<p><?php echo $d['id_device']; ?></p>
</div>
<div class="box-footer">
<a class="btn btn-default btn-block btn-lg btn-detail" href="<?php echo site_url('Setting/rule/' . $d['id_device']); ?>">View Rule</a>
</div>
</div>
</div>
<?php
}
?>
</div>
</section>
<?php $this->load->view('components/version'); ?>
</div>
Controller:
public function rulenode() {
$this->data['sub_title'] = 'Setting - Rule';
$this->load->model('Mrule');
$this->data['node'] = $this->Mrule->device();
$this->load->view('setting/rulenode', $this->data);
}
Model:
public function device() {
$this->db->select('id_device, nama_device, foto, status_device');
$this->db->from('tb_device');
$this->db->join('arduino_rule', 'id_device = id_node');
return $this->db->get()->result_array();
// var_dump($this->db->last_query());
}
<?php
$node = $this->db->get('table_name');
foreach ($node as $d) {
?>

Pagination / mysql query failing

This is a strange one, i have ammended my mysql queries to show only results "WHERE domain_available='Y' AND domain_category!='N/A' AND domain_crawler_id='0'" when i manually go in to PHPMyAdmin and do an sql query test it brings back the proper results (57) but when i run the script the rows count: echo $total_results; brings back all 1300+ results, even though i manually test in the phpmyadmin query table, it brings back the results perfectly.
<?php
include('includes/sessions.php');
include('includes/db_connection.php');
include('includes/functions.php');
include('includes/header.php');
include('includes/navbar-logged.php');
?>
<?php
$crawlId = isset($_GET['urlId']) ? $_GET['urlId'] : '';
?>
<?php
if (!isset($_GET['page'])) {
$page = 1;
} else {
$page = $_GET['page'];
}
$userInfo = get_logged_in_users_details($member);
$canEdit = false;
if ($userInfo['user_class'] === 'Site Administrator') {
$canEdit = true;
}
$sort = isset($_GET['sort']) ? $_GET['sort'] : 'domain_id';
$max_results = 500;
$from = ($page * $max_results) - $max_results;
if (isset($crawlId)) {
$rows = DB::getInstance()->select("
SELECT *
FROM `domains`
WHERE `domain_available`='Y' AND `domain_crawler_id`='{$crawlId}'
ORDER BY `{$sort}` DESC
LIMIT :from, :max_results",
[
'from' => [
'type' => PDO::PARAM_INT,
'value' => $from
],
'max_results' => [
'type' => PDO::PARAM_INT,
'value' => $max_results
]
]);
} else {
$rows = DB::getInstance()->select("
SELECT *
FROM `domains`
WHERE `domain_available`='Y' AND `domain_category`!='N/A' AND `domain_crawler_id`='0'
ORDER BY `{$sort}` DESC
LIMIT :from, :max_results",
[
'from' => [
'type' => PDO::PARAM_INT,
'value' => $from
],
'max_results' => [
'type' => PDO::PARAM_INT,
'value' => $max_results
]
]);
}
if (isset($crawlId)) {
$total_results = DB::getInstance()->selectValue("SELECT count(*) FROM `domains` WHERE`domain_crawler_id`='{$crawlId}'");
} else {
$total_results = DB::getInstance()->selectValue("SELECT count(*) FROM `domains` WHERE `domain_available`='Y' AND `domain_category`!='N/A' AND `domain_crawler_id`='0'");
}
echo $total_results;
if (count($rows) < 1) {
stderr('Sorry, <b>no</b> domains to show you yet!');
}
$backLinksData = getBackLinksByDomains($rows);
$isPremiumUser = (int)$user['paid_fees'] === 1;
?>
<div class="panel panel-primary">
<div class="panel-heading">Search for expired domains quickly.</div>
<div class="panel-body">
<form action="results.php" method="get" class="form-horizontal container-fluid" role="form">
<div class="row form-group">
<div class="col-sm-6 text-right">
<label for="" class="control-label">Domain Contains:</label>
</div>
<div class="col-sm-6">
<input type="text" name="keywords" class="form-control" size="40" />
</div>
</div>
<div class="row form-group">
<div class="col-sm-6 text-right">
<label for="" class="control-label">Anchor Contains:</label>
</div>
<div class="col-sm-6">
<input type="text" name="anchor" class="form-control" size="40" />
</div>
</div>
<div class="row form-group">
<div class="col-sm-6 text-right">
<label class="control-label">DA:</label>
</div>
<div class="col-sm-6">
<input type="number" min="0" max="100" name="da" value="0" class="form-control" />
</div>
</div>
<div class="row form-group">
<div class="col-sm-6 text-right">
<label class="control-label">PA:</label>
</div>
<div class="col-sm-6">
<input type="number" min="0" max="100" name="pa" value="0" class="form-control" />
</div>
</div>
<div class="row form-group">
<div class="col-sm-6 text-right">
<label class="control-label">TF:</label>
</div>
<div class="col-sm-6">
<input type="number" min="0" max="100" name="tf" value="0" class="form-control" />
</div>
</div>
<div class="row form-group">
<div class="col-sm-6 text-right">
<label class="control-label">CF:</label>
</div>
<div class="col-sm-6">
<input type="number" min="0" max="100" name="cf" value="0" class="form-control" />
</div>
</div>
<div class="row form-group">
<div class="col-sm-6 text-right">
<label class="control-label">Domains Born After:</label>
</div>
<div class="col-sm-6">
<input type="number" min="1990" max="2016" name="age" value="1999" class="form-control" />
</div>
</div>
<div class="row form-group">
<div class="col-sm-6 text-right">
<label class="control-label" style="display: inline-block;"> </label>
</div>
<div class="col-sm-6 text-right">
<button type="submit" name="submit" class="btn btn-default">Search</button>
</div>
</div>
</form>
</div>
<div class="panel-footer">Search for domains using <b>your</b> criteria.</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">Browse Domains - <b>*<font color="orange">spam</font>*</b> = Potential spam domain! <b>*<font color="red">HP</font>*</b> = A homepage link points to this domain!</div>
<div class="panel-body">
<table class="table table-striped table-condensed table-hover table-responsive">
<thead>
<tr>
<th>Alexa</th>
<th>Domain / Category</th>
<th>DA</th>
<th>PA</th>
<th>TF</th>
<th>CF</th>
<th>Indexed</th>
<th>Age</th>
<th>BL</th>
<th>RD</th>
<th>Found</th>
<?php if ($canEdit): ?>
<th>Actions</th>
<?php endif; ?>
</tr>
</thead>
<tbody>
<?php foreach ($rows as $row) { ?>
<?php
//$bgcolor = ($bgcolor == '#eeeeee'? '#ffffff': '#eeeeee');
$domID = $row['domain_id'];
$domNM = $row['domain_name'];
$domDT = $row['domain_date'];
$domAL = $row['domain_alexa_rank'];
$domDA = $row['domain_moz_da'];
$domPA = $row['domain_moz_pa'];
$domTF = $row['domain_tf'];
$domCF = $row['domain_cf'];
$domRD = $row['domain_ref_domains'];
$domDC = $row['domain_age'];
$domIN = $row['domain_indexed'];
$domHP = $row['domain_homepage'];
$domCT = $row['domain_category'];
$time_1 = date('Y-m-d H:i:s', strtotime($domDT . ' +1 hour'));
$time_2 = date('Y-m-d H:i:s', time());
$string = $domNM;
$array = array("sunglasses","payday","casino","viagra","cashloans","loans","sex","porn","xxx");
$spam = 0;
foreach ($array as $token) {
if (stristr($string, $token) !== FALSE) {
$spam = 1;
}
}
?>
<tr>
<td><?php echo htmlspecialchars($domAL); ?></td>
<td>
<?php
$domainUrl = $isPremiumUser ? $domNM : getObscuredUrl($domNM);
$domainCat = ($domCT == "N/A") ? "<font color=\"red\"><b>Uncategorized</b></font>" : "<font color=\"green\"><b>{$domCT}</b></font>";
?>
<b><?php echo htmlspecialchars($domainUrl); ?></b> <b>in</b> <?php echo $domainCat; ?>
<?php if ($time_2 <= $time_1) { ?>
<b>(<font color="red">NEW</font>)</b>
<?php } ?>
<?php if ($spam) { ?>
<b>*<font color="orange">spam</font>*</b>
<?php } ?>
<?php if ($domHP) { ?>
<b>*<font color="red">HP</font>*</b>
<?php } ?>
</td>
<td>
<?php echo $domDA; ?>
</td>
<td>
<?php echo $domPA; ?>
</td>
<td>
<?php echo $domTF; ?>
</td>
<td>
<?php echo $domCF; ?>
</td>
<td>
G=<?php if ($domIN == 0) { echo "<font color=\"red\"><b>No</b></font>"; } else { echo "<font color=\"green\"><b>Yes</b></font>"; } ?>
</td>
<td>
<?php if ($domDC == "????") { echo "<b><font color=\"red\">????</font></b>"; } else { echo $domDC; } ?>
</td>
<td>
<?= isset($backLinksData[$domNM]) ? $backLinksData[$domNM] : 0; ?>
</td>
<td>
<?php if (empty($domRD)) { echo "-"; } else { echo $domRD; } ?>
</td>
<td>
<b><?php echo date("m.d.y", strtotime($domDT)); ?></b>
</td>
<?php if ($canEdit): ?>
<td>(e)-(d)</td>
<?php endif; ?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<div class="panel-footer text-center">
<?php pagination($page, $total_results, $max_results) ?>
</div>
</div>
<?php
include('includes/footer.php');
I cannot see why the query works in phpmyadmin, but fails when i run the script, is there something i have overlooked, and help would be appreciated.
$crawlId is always set here, because you set it at the very top. You set it to '' though, which will still count as set.
So you might wanna use if(!empty($crawlId)) {...} instead of isset()

How to get the exact value from function shuffle in codeigniter?

Hello im just a newbie in codeigniter and i just want to ask on how to fix this problem...
i just want to make a simple quiz system and i want to shuffle all the questions from my database and display it.. the problem is when i compare the questions choices it gives me a value of unshuffle how can i solve this?
this is my controller to display my questions
public function quiz()
{
if(isset($_SESSION['username'])) {
$this->load->model('quizmodel');
$this->data['questions'] = $this->quizmodel->getQuestions();
$this->load->view('client/quiz', $this->data);
}else{
$this->load->view('home');
}
}
this is the getQuestions function from my quizmodel
public function getQuestions()
{
$this->db->select("cropscience_id, question, choice1, choice2, choice3, answer");
$this->db->from("cropscience");
$query = $this->db->get();
return $query->result();
$num_data_returned = $query->num_rows;
if ($num_data_returned < 1) {
echo "There is no data in the database";
exit();
}
}
this is my quiz view
<div class="panel-body">
<form method="post" action="<?php echo base_url();?>index.php/client_controller/resultdisplay">
<?php shuffle($questions); ?>
<?php foreach($questions as $row) { ?>
<?php $ans_array = array($row->choice1, $row->choice2, $row->choice3, $row->answer);
shuffle($ans_array); ?>
<div class="alert alert-success">
<p><?=$row->question?></p>
<br>
<div class="radio radio-success radio-inline">
<input type="radio" name="<?php echo $row->cropscience_id ?>" value="<?=$ans_array[0]?>" required>
<label for="inlineRadio1"> <?=$ans_array[0]?> </label>
</div>
<div class="radio radio-success radio-inline">
<input type="radio" name="<?php echo $row->cropscience_id ?>" value="<?=$ans_array[1]?>">
<label for="inlineRadio1"> <?=$ans_array[1]?> </label>
</div>
<div class="radio radio-success radio-inline">
<input type="radio" name="<?php echo $row->cropscience_id ?>" value="<?=$ans_array[2]?>">
<label for="inlineRadio1"> <?=$ans_array[2]?> </label>
</div>
<div class="radio radio-success radio-inline">
<input type="radio" name="<?php echo $row->cropscience_id ?>" value="<?=$ans_array[3]?>">
<label for="inlineRadio1"> <?=$ans_array[3]?> </label>
</div>
</div>
<?php } ?>
<div align="center" >
<div class="btn btn-primary btn-rounded">
<i class="fa fa-check"></i><input class="btn btn-primary btn-rounded" type="submit" value="Submit!">
</div>
</div>
</form>
</div>
this is my resultdisplay function from my controller
public function resultdisplay()
{
if(isset($_SESSION['username'])) {
$this->load->model('quizmodel');
$qID = $this->quizmodel->getQuizID();
$this->data['checks'] = $this->input->post($qID);
$this->load->model('quizmodel');
$this->data['results'] = $this->quizmodel->resultsScore();
$this->load->view('client/result_display', $this->data);
}else{
$this->load->view('home');
}
}
this is my result_display view
div class="wrapper wrapper-content">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h1 style="color: white;">Results</h1>
</div>
<div class="panel-body">
<?php $score = 0; ?>
<?php $array1= array(); ?>
<?php $array2= array(); ?>
<?php $array3= array(); ?>
<?php $array4= array(); ?>
<?php $array5= array(); ?>
<?php $array6= array(); ?>
<?php $array7= array(); ?>
<?php $array8= array(); ?>
<?php $count = 0; ?>
<?php foreach($checks as $checkans) { ?>
<?php echo $checkans; ?>
<?php $array1[$count] = $checkans;
$count++; ?>
<?php }?>
<br><br>
<?php foreach($results as $res) { ?>
<?php $array2[] = $res->answer;
$array3[] = $res->cropscience_id;
$array4[] = $res->question;
$array5[] = $res->choice1;
$array6[] = $res->choice2;
$array7[] = $res->choice3; ?>
<?php } ?>
<?php for ($x=0; $x <= $array3[$x]; $x++) { ?>
<?php echo $array4[$x]; ?>
<?php if ($array2[$x] != $array1[$x]) { ?>
<div class="alert alert-danger">
<p><i class="fa fa-times"></i></p>
<p><span style="background-color: #FF9C9E"><?=$array1[$x]?></span></p>
<p><span style="background-color: #ADFFB4"><?=$array2[$x]?></span></p>
</div>
<?php } else { ?>
<div class="alert alert-success">
<p><i class="fa fa-check"></i></p>
<p><span style="background-color: #ADFFB4"><?=$array1[$x]?></span></p>
</div>
<?php $score = $score + 1 ?>
<?php } ?>
<?php } ?>
<div align="center">
<input type="hidden" name="score" value="<?=$score?>">
<input type="button" class="btn btn-primary" data-toggle="modal" data-target="#scoremodal" value="View Your Score">
<!-- Score Modal Body -->
<div class="modal inmodal fade" id="scoremodal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-body" align="center">
<h2>Your Score is: </h2>
<h1><?=$score?>/100</h1>
</div>
<div class="modal-footer">
<?php echo form_open('client_controller/save_score'); ?>
<form method="get">
<div align="center">
<input type="hidden" name="score" value="<?=$score?>">
<input type="submit" class="btn btn-primary" value="Ok">
</div>
</form>
<?php echo form_close(); ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
this is my getQuizID() function model
public function getQuizID()
{
$this->db->select("cropscience_id");
$this->db->from("cropscience");
$query = $this->db->get();
}
this is my resultsScore() function model
public function resultsScore()
{
$this->db->select("cropscience_id, question, choice1, choice2, choice3, answer");
$this->db->from("cropscience");
$query = $this->db->get();
return $query->result();
$num_data_returned = $query->num_rows;
}
please help thank you
make a query like this:
$this->db->order_by('id', 'RANDOM');
or
$this->db->order_by('rand()');
$query = $this->db->get('cropscience');
return $query->result_array();

Codeigniter : Multiple columns of the same row Update query not working

I am not able to update multiple columns of the same row with the row matching the userid in codeigniter.
My controller Code is :
exits.php
function update_act_on_resignation(){
global $SITE,$USER;
$data = array();
$data['row'] = new stdClass();
$data['row'] = $this->admin_init_elements->set_post_vals($this->input->post());
$data['offices']=$this->mod_common->get_all_offices();
$clients = currentuserclients();
$data['roles'] = $this->mod_common->get_cat_array('designation','status',"1' AND id > '0",'designation');
get_city_state_country_array($data,array('cityid'=>$data['row']->cityid));
$data['error_message'] = '';
$data['row']->id = $this->uri->segment(3);
$data['id'] = $this->uri->segment(3);
$data['action'] = 'add';
$data['heading'] = 'Add';
$data['msg_class'] = 'sukses';
$data['path']=$path;
$post_action = $this->input->post('action');
if($post_action=='add' || $post_action =='update' ){
$post_array = $this->input->post();
$action = ($post_action == 'add')?'inserted':'updated';
//echo '<pre>';print_r($SITE);die;
echo $post_array['exit_type'] = 'Employee Initiated';
echo $post_array[$id] = $USER->id;
echo $post_array['custom-105965'];
echo $post_array['manager_comments'];
echo $post_array['accept'];
echo $post_array['agreed_last_date'];
$data['success_message'] = $this->exit_common->update_get_resignation_to_act($post_array,$action);
if($data['success_message'] == 'Record '.$action.' successfully'){
$data['row'] = new stdClass();
$data['row']->id = $this->uri->segment(3);
$data['row']->status = 1;
}
}
$this->data['maincontent'] = $this->load->view('maincontents/view_resignation_action', $data,true);
echo "Resignation withdrawn successfully!";
$this->load->view('layout', $this->data);
}
I am echoing the results got from a form to check if i am receiving the sent form elements and i have received everything properly. i.e i am recieving 67 for $post_array[$id] Yes for $post_array['custom-105965'] asd for $post_array['manager_comments'] Accept for $post_array['accept'] and 01-01-1970 as $post_array['agreed_last_date'] after the echo.
My Model code is:
exit_common.php
function update_get_resignation_to_act($post_array,$action){
$this->load->database();
$this->db->where('userids', $post_array['id']);
$dbdata['discussion'] = $post_array['custom-105965'];
$dbdata['manager_comments'] = $post_array['manager_comments'];
$dbdata['last_status'] = $post_array['accept'];
$dbdata['agreed_date'] = $post_array['agreed_last_date'];
$this->db->update('pr_resignation_requests', $dbdata);
return;
}
I think something is wrong with the model update function. But not able to figure out what is wrong as a similar function is working for updating a single column in db. Am i missing something? Its a mysql db.
My View Code is:
view_resignation_action.php
<style>
label{font-weight:bold;}
.hbox .col {
display: table-cell;
float: none;
height: 100%;
vertical-align: top;
width:100%;
}
</style>
<div class="new">
<section class="content-header">
<h1>
Resignation Action
</h1>
<ol class="breadcrumb" >
<li><i class="fa fa-home"></i> Home</li>
<li>People Connect</li>
<li>Exit Tracker</li>
<li class="active">Exit Details</li>
</ol>
</section>
<input type="hidden" id="page_name" value="requests">
<div class="container-fluid">
<div class="row">
<!-- Thought Day-->
<div class="panel wrapper clearfix m-b-none">
<!-- Horizontal Form -->
<div class="box-header with-border">
</div><!-- /.box-header -->
<!-- form start -->
<?php if($error_message!=''){?>
<div class="row-fluid return-message success-message <?php echo $msg_class; ?>"><?php echo $error_message;?></div>
<?php } else { ?>
<?php echo form_open('exits/update_act_on_resignation/',array('name'=>'addostcstevent','id'=>'addostcstevent','method'=>'post','autocomplete'=>'on','class'=>'form-horizontal'))?>
<?php echo form_hidden(array('id'=>$USER->id,'action'=>$action));?>
<?php foreach($rows as $row){ ?>
<div class="panel-body">
<div class="control-group form-group">
<div class="col-md-6">
<div class="controls">
<div class="col-md-5">
<label class="control-label" style="text-align:left">Name of the employee </label>
<div class="controls"><?php echo $row->firstname; ?>
</div>
</div>
<div class="col-md-5">
</div>
</div>
</div>
<div class="col-md-6 pull-right">
<label class="control-label" style="text-align:left">Date of request </label><div class="controls">
<?php echo $row->resignations_date; ?>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="control-group form-group">
<div class="col-md-6 ">
<label class="control-label" style="text-align:left">Requested Last Working Date</label>
<div class="controls">
<div class="col-md-10">
<?php echo $row->requested_date; ?>
</div>
</div>
</div>
<div class="col-md-6 pull-right">
<label class="control-label">Reason</label>
<div class="controls">
<div class="col-md-9">
<?php echo $row->exit_type; ?>
</div>
</div>
</div>
<div class="col-md-6 pull-right">
<label class="control-label">Comments from Employee</label>
<div class="controls">
<div class="col-md-9">
<?php echo $row->comments; ?>
</div>
</div>
</div>
<br><br><br><br><br><br><br>
<fieldset id="f1" class="col-md-6 pull-left"> <!-- start fieldset -->
<div class="label">
</label>
</div>
<div class="input">
</div>
</div>
</td>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%" style="text-align:left">
<label class="control-label" style="text-align:left">Have you had a discussion with Employee?</label>
<table>
<td valign="top">
<input id="custom-105965_0" class="custom-105965" name="custom-105965" value="Yes" type="radio">
<label for="custom-105965_0">Yes
<br>
</label>
</td>
<td valign="top">
<input id="custom-105965_1" class="custom-105965" name="custom-105965" value="No" type="radio">
<label for="custom-105965_1">No
</label>
</td>
</table>
<td valign="top">
<div class="fieldset" id="bsd-field-custom-105967-group">
<div class="col-md-6 pull-left">
<label class="control-label">Please enter your comments</label>
<div class="controls">
<div class="col-md-12">
<textarea required class="form-control" name="manager_comments"></textarea>
<!--<input placeholder="Please enter your comments" class="" id="dateofrequest" type="text" name="todays_date" value=""/> <br><br>-->
</div>
</div>
<label class="control-label">Action</label>
<div class="controls">
<div class="col-md-9">
<?php $dd_list = array(
'Accept' => 'Accepted',
'Reject' => 'Rejected',
);
echo form_dropdown('accept', $dd_list, 'Accept');
?>
</div>
</div>
<label class="control-label">Agreed Last Working day</label>
<div class="controls">
<div class="col-md-9">
<input placeholder="Agreed Last Working day" class=" m-wrap col-md-8 form-control " id="startdt" type="text" name="agreed_last_date" value="<?php if($row->requested_date!='') echo date("d-m-Y",$row->requested_date); ?>" required/>
</div>
</div>
<br><br>
<div class="col-md-9">
</div>
</div>
</div>
<!-- If its a no -->
<div class="fieldset" id="bsd-field-custom-105867-group">
<div class="col-md-6 pull-left">
<div class="alert alert-success alert-dismissable">
<label type="button"></label>
Please have a discussion with the employee.
</div>
</div>
</div>
</td>
</table>
</td>
</tr>
</fieldset><!-- End Fiedset -->
</div>
</div>
<?php }?>
<div class="clearfix"></div>
<div class=" box-footer">
<button type="submit" class="btn btn-info pull-right" style="margin:0px 10px">submit</button>
</div>
</form>
<?php } ?>
<div class="clearfix"></div>
</div>
</div>
</div>
</section>
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/plugins/bootstrap-fileupload/bootstrap-fileupload.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/plugins/select2/select2.min.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/plugins/bootstrap-timepicker/js/bootstrap-timepicker.js"></script>
<script>
$(".fieldset").hide();
$(document).ready(function () {
$("[id^=bsd-field-custom-1059]").hide();
$(".custom-105965").change(function () {
$("[id^=bsd-field-custom-1059]").toggle(this.value == 'Yes');
});
});
$(document).ready(function () {
$("[id^=bsd-field-custom-1059]").hide();
$(".custom-105965").change(function () {
$("[id^=bsd-field-custom-1058]").toggle(this.value == 'No');
$('.alert').show()
});
});
$(document).ready(function(){
$("#startdt").datepicker({
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: "-90:+0",
endDate: new Date(),
autoclose: true
}).on('changeDate', function (selected) {
var minDate = new Date(selected.date.valueOf());
$('#enddt').datepicker('setStartDate', minDate);
});
$("#enddt").datepicker({
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: "-90:+0",
endDate: new Date()
});
$(".date-picker").datepicker();
$('.timepicker-default').timepicker();
$('#report_date').datepicker( {
format: "mm-yyyy",
viewMode: "months",
minViewMode: "months"
});
$(".select2").select2({
placeholder: "Select an option",
allowClear: true
});
$("#asset_type").change(function(){
if($(this).val() == '-1') {
$("#new_type").show();
}
else
{
$("#new_type").hide();
}
});
$("#manufacturer").change(function(){
if($(this).val() == '-1') {
$("#new_manufacturer").show();
}
else
{
$("#new_manufacturer").hide();
}
});
$("#supplier").change(function(){
if($(this).val() == '-1') {
$("#new_supplier").show();
}
else
{
$("#new_supplier").hide();
}
});
});
</script>
Mysql Table is :
Try Below Snippet
function update_get_resignation_to_act($post_array,$action)
{
$this->load->database();
$this->db->where('userids', $post_array['id']);
$dbdata = array(
"discussion" => $post_array['custom-105965'],
"manager_comments" => $post_array['manager_comments'],
"last_status" => $post_array['accept'],
"agreed_date" => $post_array['agreed_last_date']
);
$this->db->update('pr_resignation_requests', $dbdata);
/**
* if required add this code here to check
*
* echo $this->db->last_query();
*/
return;
}

page having query string expires if navigating back to that page in codeigniter

i am using query string to get the search parameters entered by user, in codeigniter but if i am going on another page, and then navigating back to that page, then, page expires and i has to be reload that page to get that page with search result.
so, any technique in codeigniter, using which we can get page having search results immediately when navigating back to that page.
public function search_freelancer($limit,$offset)
{
$query="SELECT FM.freelancer_id, FM.first_name, FM.last_name, FD.professional_title, FD.profile_image, FD.freelancer_rate, FD.availability_to_work, FD.country_id, FD.city, FD.user_type, FD.company_name, cm.country_name, FD.overview, GROUP_CONCAT( SM.skill_name SEPARATOR ', ' ) AS skills
FROM freelancer_master AS FM
LEFT JOIN freelancer_skill AS FS ON ( FS.freelancer_id = FM.freelancer_id )
LEFT JOIN freelancer_detail AS FD ON ( FD.freelancer_id = FM.freelancer_id )
LEFT JOIN skill_master AS SM ON ( FS.skill_id = SM.skill_id )
LEFT JOIN country_master AS cm ON cm.country_id = FD.country_id
WHERE FD.professional_title LIKE '%".$this->input->get('search_query',TRUE)."%'
GROUP BY FM.freelancer_id
LIMIT ".$limit."
OFFSET ".$offset;
$data=$this->db->query($query);
if($data->num_rows() > 0)
{
$results=$data->result();
return $results;
}
else
{
$results=NULL;
return $results;
}
}
controller :
public function search_freelancer($limit,$offset)
{
$this->output->cache(60);
$data['freelancers']=$this->search_model->search_freelancer($limit,$offset);
if($data != NULL) {
$data['categories']=$this->freelancer_profile_model->get_categories();
$this->load->view('search',$data);
$this->load->view('template/footer');
}
}
view :
<script type="text/javascript" src="<?php echo base_url(); ?>js/country-suggest.js"></script>
<div class="advance-search-container bg-light-gray">
<div class="login-container">
<div class="container">
<h1>Search</h1>
<hr/>
<div class="row">
<div class="col-lg-12">
<div class="search-container">
<div class="search-div">
<div class="simple-search">
<form name="simple_searcg" id="simple_searcg" class="simple_searcg" method="post" action="" >
<div class="text-center col-lg-10 col-xs-12 col-sm-10 col-md-10" style="float:left;">
<div class="input-area">
<input type="text" name="search" id="search" class="input-box" placeholder="Search" value="<?php echo set_value('search'); ?>" style="height:40px;">
<span class="text-danger" id="error"></span>
</div><!--end of input-area-->
</div><!--end of center-->
<div class="text-center col-lg-2 col-xs-12 col-sm-2 col-md-2">
<div class="btn-row">
<input type="submit" class="btn btn-info simple_search" value="submit" id="submit" name="submit"/>
</div><!--nmd of btn-row-->
</div>
</div><!--end of simple-search-->
<div class="advance-search">
<div class="text-center col-lg-3 col-sm-3 col-md-3 col-xs-12">
<div class="input-area">
<select name="category_id" id="category" value="<?php echo set_value('category_id'); ?>" style="height:40px" >
<option value="">Select Category</option>
<?php if(!empty($categories)) {
foreach($categories as $row) { ?>
<option value="<?php echo $row->category_id; ?>"><?php echo $row->category_name; ?></option>
<?php } } ?>
</select>
</div><!--end of input-area-->
</div><!--end of center-->
<div class="text-center col-lg-3 col-sm-3 col-md-3 col-xs-12">
<div class="input-area">
<select name="subcategory_id" id="sub_category" value="<?php echo set_value('subcategory_id'); ?>" style="height:40px" >
<option value="">Select Subcategory</option>
</select>
</div><!--end of input-area-->
</div><!--end of center-->
<div class="text-center col-lg-3 col-sm-3 col-md-3 col-xs-12">
<div class="input-area">
<input type="text" name="country_name" id="country_name" value="<?php echo set_value('country_name'); ?>" class="input-box" placeholder="Country Name" autocomplete="off">
<input type="hidden" name="country_id" id="country_id" value="<?php echo set_value('country_id'); ?>" class="input-box" placeholder="Country Name">
<div id="display_suggestions"></div>
</div><!--end of input-area-->
</div><!--end of center-->
<div class="text-center col-lg-2">
<div class="btn-row">
<input type="submit" class="btn btn-info filter_search" value="submit" id="submit" name="submit"/>
</div><!--nmd of btn-row-->
</div>
</form>
<span class="text-danger" id="errors"></span>
</div><!--end of advance-search-->
<div class="recruiter-search-detail">
<?php if(!empty($freelancers)) {
foreach($freelancers as $row) { ?>
<div class="search-box">
<div class="image-div col-lg-3 col-sm-3 col-md-3 col-xs-12"> <img id="imgProfile" title="Change profile photo" class="profilePic dropzone img-circle" alt="profile image" src="<?php echo base_url().'upload/profileimage/'.$row->profile_image; ?>" /></div><!--end of col-lg-3-->
<div class="recruiter-profile col-lg-9 col-sm-9 col-md-9 col-xs-12">
<p class="freelancer-name"><?php echo $row->first_name." ".$row->last_name; ?><span class="usertype"><?php echo " ".$row->user_type; ?><?php if($row->company_name != "") {echo " | ".$row->company_name;} ?></span> <span class="rate"><?php echo $row->freelancer_rate.'/hr'; ?></span></p>
<p class="professional-title"><?php echo $row->professional_title; ?><span class="availability"><?php echo $row->availability_to_work; ?></span></p>
<p class="location"><i class="fa fa-map-marker"></i><?php echo $row->city.", ".$row->country_name; ?></p>
<p class="overview"><?php echo $row->overview; ?>more...</p>
<?php $skills=explode(', ',$row->skills); ?>
<p class="skills">
<?php for($i=0;$i<count($skills);$i++) { ?>
<span><?php echo $skills[$i]; ?></span>
<?php } ?>
</p>
</div>
</div><!--end of search-box-->
<?php } } else {
echo 'No Results'; } ?>
</div><!--end of recruiter-search-detail-->
</div><!--end fo search-div-->
</div><!--end of search-container-->
</div>
</div>
</div><!--en dof login-container-->
</div>
</div>
<script>
$(document).ready(function(){
// loading all subcategories on change of categories
$('#category').change(function(){
var id=$('#category').val();
$.ajax({
type: "POST",
url: "<?php echo base_url(); ?>freelancer/load_subcategories/"+id,
dataType: "json",
success:function(data) {
$('#sub_category').html("");
$('#sub_category').html("<option value=''>Select Subcategory</option>");
for(i=0;i<data.length;i++) {
$('#sub_category').append("<option value='"+data[i].subcategory_id+"'>"+data[i].subcategory_name+"</option>");
}
}
});
});
$('.simple_search').click(function (e) {
if($('#search').val() == "") {
e.preventDefault();
$('#error').html("search query required !");
$('#error').show().delay(7000).fadeOut();
}
else if($('#search').val().length < 3) {
e.preventDefault();
$('#error').html("enter 3 or more characters !");
$('#error').show().delay(7000).fadeOut();
}
else {
//$('#simple_searcg').submit();
$('#simple_searcg').attr('action', '<?php echo base_url() ?>'+'search/search_freelancer/1/0/?search_query='+$('#search').val()+'&cat='+$('#category').val()+'&subcat='+$('#sub_category').val()+'&cnt='+$('#country_id').val());
//$(location).attr("href", '<?php echo base_url() ?>'+'search/search_freelancer/1/0/?search_query='+);
}
});
$('.filter_search').click(function (e) {
if($('#search').val() == "" && $('#category').val() == "" && $('#sub_category').val() == "" && $('#country_name').val() == "") {
e.preventDefault();
$('#errors').html("atleast one parameter required !");
$('#errors').show().delay(7000).fadeOut();
}
else {
$('#simple_searcg').attr('action', '<?php echo base_url() ?>'+'search/search_filter_freelancer/1/0/?search_query='+$('#search').val()+'&cat='+$('#category').val()+'&subcat='+$('#sub_category').val()+'&cnt='+$('#country_id').val());
//$('#simple_searcg').submit();
}
});
});
</script>

Categories