editing php page to insert new value to my table - php

hey I'm Newbie and want to edit php page and adding some extra code so my problem is
I added new column to my table and I want to send data from new input text to my table to new column
I add the input text and now I wand to insert that data in new column
even I didn't find the insert query to editing it
my code is below
<?php include_once 'asset/admin-ajax.php'; ?>
<?php echo message_box('success'); ?>
<?php echo message_box('error'); ?>
<div class="row">
<div class="col-sm-12">
<div class="wrap-fpanel">
<div class="panel panel-default" data-collapsed="0">
<div class="panel-heading">
<div class="panel-title">
<strong><?php echo $this->language->form_heading()[13] ?></strong>
</div>
</div>
<div class="panel-body">
<form id="form" action="<?php echo base_url() ?>admin/employee/save_employee_award/<?php
if (!empty($award_info->employee_award_id)) {
echo $award_info->employee_award_id;
}
?>" method="post" enctype="multipart/form-data" class="form-horizontal">
<div class="panel_controls">
<div class="form-group" id="border-none">
<label for="field-1" class="col-sm-3 control-label"><?php echo $this->language->from_body()[14][0] ?> <span class="required">*</span></label>
<div class="col-sm-5">
<select name="designations_id" class="form-control" onchange="get_employee_by_designations_id(this.value)">
<option value="">اختر تعيين.....</option>
<?php if (!empty($all_department_info)): foreach ($all_department_info as $dept_name => $v_department_info) : ?>
<?php if (!empty($v_department_info)): ?>
<optgroup label="<?php echo $dept_name; ?>">
<?php foreach ($v_department_info as $designation) : ?>
<option value="<?php echo $designation->designations_id; ?>"
<?php
if (!empty($award_info->designations_id)) {
echo $designation->designations_id == $award_info->designations_id ? 'selected' : '';
}
?>><?php echo $designation->designations ?></option>
<?php endforeach; ?>
</optgroup>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
</select>
</div>
</div>
<div class="form-group" id="border-none">
<label for="field-1" class="col-sm-3 control-label"><?php echo $this->language->from_body()[14][1] ?> <span class="required">*</span></label>
<div class="col-sm-5">
<select name="employee_id" id="employee" class="form-control" >
<option value="">اختر موظف...</option>
<?php if (!empty($employee_info)): ?>
<?php foreach ($employee_info as $v_employee) : ?>
<option value="<?php echo $v_employee->employee_id; ?>"
<?php
if (!empty($award_info->employee_id)) {
echo $v_employee->employee_id == $award_info->employee_id ? 'selected' : '';
}
?>><?php echo $v_employee->first_name . ' ' . $v_employee->last_name ?></option>
<?php endforeach; ?>
<?php endif; ?>
</select>
</div>
</div>
<div class="form-group">
<label for="field-1" class="col-sm-3 control-label"><?php echo $this->language->from_body()[14][2] ?> <span class="required">*</span></label>
<div class="col-sm-5">
<input type="text" name="award_name" class="form-control" value="<?php
if (!empty($award_info->award_name)) {
echo $award_info->award_name;
}
?>" />
</div>
</div>
<div class="form-group">
<label for="field-1" class="col-sm-3 control-label"> new column <span class="required">*</span></label>
<div class="col-sm-5">
<input type="text" name="new_column" class="form-control" value="<?php
if (!empty($award_info->new_column)) {
echo $award_info->new_column;
}
?>" />
</div>
</div>
<div class="form-group">
<label for="field-1" class="col-sm-3 control-label"><?php echo $this->language->from_body()[14][3] ?></label>
<div class="col-sm-5">
<input type="text" name="gift_item" class="form-control" value="<?php
if (!empty($award_info->gift_item)) {
echo $award_info->gift_item;
}
?>" />
</div>
</div>
<div class="form-group">
<label for="field-1" class="col-sm-3 control-label"><?php echo $this->language->from_body()[14][4] ?></label>
<div class="col-sm-5">
<input type="text" name="award_amount" class="form-control" value="<?php
if (!empty($award_info->award_amount)) {
echo $award_info->award_amount;
}
?>" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"><?php echo $this->language->from_body()[14][5] ?> <span class="required">*</span></label>
<div class="col-sm-5">
<div class="input-group">
<input type="text" name="award_date" placeholder="ادخل الشهر" class="form-control monthyear" value="<?php
if (!empty($award_info->award_date)) {
echo $award_info->award_date;
}
?>" data-format="dd-mm-yyyy">
<div class="input-group-addon">
<i class="entypo-calendar"></i>
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-5">
<button type="submit" id="sbtn" name="sbtn" value="1" class="btn btn-primary"><?php echo $this->language->from_body()[1][12] ?></button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12" data-offset="0">
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-title">
<span>
<strong><?php echo $this->language->from_body()[14][6] ?></strong>
</span>
</div>
</div>
<!-- Table -->
<table class="table table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th class="col-sm-1">رقم الموظف</th>
<th>اسم الموظف</th>
<th>اسم المكافئة</th>
<th>بند المكافئة</th>
<th>مبلغ الكافئة</th>
<th>الشهر</th>
<th> : اجراء</th>
</tr>
</thead>
<tbody>
<?php if (!empty($all_employee_award_info)):foreach ($all_employee_award_info as $v_award_info): ?>
<tr>
<td><?php echo $v_award_info->employment_id ?></td>
<td><?php echo $v_award_info->first_name . ' ' . $v_award_info->last_name; ?></td>
<td><?php echo $v_award_info->award_name;?></td>
<td><?php echo $v_award_info->gift_item; ?></td>
<td><?php echo $v_award_info->award_amount;?></td>
<td><?php echo date('F y', strtotime($v_award_info->award_date)) ?></td>
<td>
<?php echo btn_edit('admin/employee/employee_award/' . $v_award_info->employee_award_id . '/' . $v_award_info->designations_id); ?>
<?php echo btn_delete('admin/employee/delete_employee_award/' . $v_award_info->employee_award_id); ?>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
anyone for help please

To check the full path of the file copy paste the code at the top of the file and then you can easily go to the directory where the file is located.
<? echo base_url().'admin/employee/save_employee_award/'; exit; ?>

Related

Html is still visible in CodeIgniter using if else

I'm here trying to make if else condition to hiding the html part if $addons_facts var is empty. I am making the addon visible on the food item if the $addons_facts var is not empty.
<?php $addon_data = $this->addons_model->get_addon_by_menu_id($menu_details['id']);
$addons_facts = json_decode($addon_data->addon_fact, true);
?>
<?php if(!empty($addons_facts) && $addons_facts !=='') : ?>
<div class="form-group">
<div class="row">
<div class="col-md-12">
<?php
foreach ($addons_facts as $key => $addon_fact) : ?>
<div class="row">
<div class="col-md-1">
<div class="checkbox">
<label for="check">
<input type="checkbox" id="check" />
<span class="fake-input"></span>
</label>
</div>
</div>
<div class="col-md-7 text-left">
<?php echo sanitize($key); ?>
</div>
<div class="col-md-3">
<?php echo currency(sanitize($addon_fact));?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<?php endif; ?>
When data is present in $addons_facts
When data is absent $addons_facts
As you can clearly see that when data is not present and the html is still visible (checkbox or $). I already tried if else both but unable to figure it out what is going wrong and why if condition not hiding the whole content within if{}.
I figure it out the solution by this: <?php if(!empty($key)) : ?>
<div class="form-group">
<div class="row">
<div class="col-md-12">
<?php
foreach ($addons_facts as $key => $addon_fact) : ?>
<?php if(!empty($key)) : ?>
<?php $randomNum = substr(str_shuffle("0123456789abcdefghijklmnopqrstvwxyzABCDEFGHIJKLMNOPQRSTVWXYZ"), 0, 10); ?>
<div class="row">
<div class="col-1">
<div class="checkbox">
<label for="<?php echo $randomNum; ?>">
<input type="checkbox" id="<?php echo $randomNum; ?>" />
<span class="fake-input"></span>
</label>
</div>
</div>
<div class="col-7 text-left">
<?php echo sanitize($key); ?>
</div>
<div class="col-3">
<?php echo sanitize($addon_fact) ? currency(sanitize($addon_fact)) :'';?>
</div>
</div>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
</div>

bootstrap 4 with codeignitor form with validation

Not showing responsive in safari browser Responsive issue
I am unable to control to responsive this code, working fine in windows chrome and Mozilla, but not on mac. can anyone help me?
<?php echo form_open('user/signup');?>
<div class="form-row">
<div class="form-group">
<div class="col-md-6 col-xs-12 col-sm-12">
<div class="form-label-group">
<?php echo form_input(['name'=>'firstname','id'=>'firstname','class'=>'form-control','autofocus'=>'autofocus','value'=>set_value('firstname')]);?>
<?php echo form_label('Enter your first name', 'firstname'); ?>
<?php echo form_error('firstname',"<div style='color:red'>","</div>");?>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-xs-12 col-sm-12">
<div class="form-label-group">
<?php echo form_input(['name'=>'lastname','id'=>'lastname','class'=>'form-control','autofocus'=>'autofocus','value'=>set_value('lastname')]);?>
<?php echo form_label('Enter your last name', 'lastname'); ?>
<?php echo form_error('lastname',"<div style='color:red'>","</div>");?>
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="form-label-group">
<?php echo form_input(['name'=>'emailid','id'=>'emailid','class'=>'form-control','autofocus'=>'autofocus','value'=>set_value('emailid')]);?>
<?php echo form_label('Enter valid email id', 'emailid'); ?>
<?php echo form_error('emailid',"<div style='color:red'>","</div>");?>
</div>
</div>
<div class="form-group">
<div class="form-label-group">
<?php echo form_input(['name'=>'mobilenumber','id'=>'mobilenumber','class'=>'form-control','autofocus'=>'autofocus','value'=>set_value('mobilenumber')]);?>
<?php echo form_label('Enter Mobile Number', 'mobilenumber'); ?>
<?php echo form_error('mobilenumber',"<div style='color:red'>","</div>");?>
</div>
</div>
<div class="form-group">
<div class="form-row">
<div class="col-md-6">
<div class="form-label-group">
<?php echo form_password(['name'=>'password','id'=>'password','class'=>'form-control','autofocus'=>'autofocus','value'=>set_value('password')]);?>
<?php echo form_label('Password', 'password'); ?>
<?php echo form_error('password',"<div style='color:red'>","</div>");?>
</div>
</div>
<div class="col-md-6">
<div class="form-label-group">
<?php echo form_password(['name'=>'confirmpassword','id'=>'confirmpassword','class'=>'form-control','autofocus'=>'autofocus','value'=>set_value('confirmpassword')]);?>
<?php echo form_label('Confirm Password', 'confirmpassword'); ?>
<?php echo form_error('confirmpassword',"<div style='color:red'>","</div>");?>
</div>
</div>
</div>
</div>
<?php echo form_submit(['name'=>'Register','value'=>'Register','class'=>'btn btn-primary btn-block']); ?>
<?php echo form_close(); ?>
How do I solve this issue
Responsive issue on safari
100% working in windows chrome

How do I direct inline HTML to a variable?

This PHP code outputs HTML to the user.
<div class="whole">
<input type="hidden" class="hid" name="hid" value="<?php echo $datum['id']; ?>">
<div class="col1"> <div class="d1" id="naam<?php echo $datum['id']; ?>"><?php echo $datum['name']; ?></div>
</div>
<div class="col2"> <div class="d2" id="email<?php echo $datum['id']; ?>"><?php echo $datum['email']; ?></div>
</div>
<div class="col3"> <div class="d3" id="state<?php echo $datum['id']; ?>"><?php echo $datum['state']; ?></div>
</div>
<div class="col4"> <div class="d4" id="gender<?php echo $datum['id']; ?>"><?php echo $datum['gender']; ?></div>
</div>
<div class="col5"> <div class="d5" id="lang<?php echo $datum['id']; ?>"><?php echo $datum['lang']; ?></div>
</div>
<div class="col6">
<?php
echo "<a href='images/".$datum['image']."' data-lightbox='picbox' data-title='".$datum['image']."'> <img src='images/".$datum['image']."'></a>";
?>
</div>
</div>
Instead of sending this output to the user, I want it in the variable $output. How can I do this?
You can use Jquery to get HTML code inside your div:
$( document ).ready(function() {
data = $(".whole").html();
console.log(data);
});
Where data is:
<input type="hidden" class="hid" name="hid" value="<?php echo $datum['id']; ?>">
<div class="col1"> <div class="d1" id="naam<?php echo $datum['id']; ?>"><!--?php echo $datum['name']; ?--></div>
</div>
<div class="col2"> <div class="d2" id="email<?php echo $datum['id']; ?>"><!--?php echo $datum['email']; ?--></div>
</div>
<div class="col3"> <div class="d3" id="state<?php echo $datum['id']; ?>"><!--?php echo $datum['state']; ?--></div>
</div>
<div class="col4"> <div class="d4" id="gender<?php echo $datum['id']; ?>"><!--?php echo $datum['gender']; ?--></div>
</div>
<div class="col5"> <div class="d5" id="lang<?php echo $datum['id']; ?>"><!--?php echo $datum['lang']; ?--></div>
</div>
<div class="col6">
<!--?php
echo "<a href='images/".$datum['image']."' data-lightbox='picbox' data-title='".$datum['image']."'--> <img src="images/".$datum[" image']."'="">";
?>
After that you can send data to PHP via AJAX
<?php
ob_start();
?>
your html goes here
<?php
$html = ob_get_contents();
ob_end_clean();
Use heredoc syntax, like so:
$output = <<<ANY_IDENTIFIER_THAT_DOES_NOT_APPEAR_IN_THE_TEXT_HERE
<div class="whole">
<input type="hidden" class="hid" name="hid" value="{$datum['id']}">
<div class="col1"> <div class="d1" id="naam{$datum['id']}">{$datum['name']}</div>
</div>
<div class="col2"> <div class="d2" id="email{$datum['id']}">{$datum['email']}</div>
</div>
<div class="col3"> <div class="d3" id="state{$datum['id']}">{$datum['state']}</div>
</div>
<div class="col4"> <div class="d4" id="gender{$datum['id']}">{$datum['gender']}</div>
</div>
<div class="col5"> <div class="d5" id="lang{$datum['id']}">{$datum['lang']}</div>
</div>
<div class="col6">
<a href='images/{$datum['image']}' data-lightbox='picbox' data-title='{$datum['image']}'> <img src='images/{$datum['image']}'></a>
</div>
</div>
ANY_IDENTIFIER_THAT_DOES_NOT_APPEAR_IN_THE_TEXT_HERE;
This last part must be exactly the same identifier as at the beginning, unindented and followed by a semicolon.
Also, note that I took out all of the <?php ?> sections, and replaced them with {$datum['image']} accesses (unless I missed one). Heredocs in PHP work just like "double quoted strings", except spread across multiple lines and able to include " marks.
For more information, see the PHP documentation on string syntax.

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()

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