hi all,
i want to fetch data dynamically from database using ajax call with one select and other autofill using ajax call
i am unable to my code is like this:
VIEW
MODEL
[/php]
CONTROLLER:
i am stuck please help me with this..thanku so much in advance.
i want to fetch data dynamically from database using ajax call with one select and other autofill using ajax call
i am unable to my code is like this:
VIEW
PHP Code:
<?php include_once "vwHeader.php" ?>
<html>
<head>
<style>
table {
width:100%;
}
table , thead
{
background: #4682B4;
color:white;
}
table, th, td {
border: 1px solid white;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
td{
color:black;
}
table#t01 tr:nth-child(even) {
background-color: #eee;
}
table#t01 tr:nth-child(odd) {
background-color:#fff;
}
table#t01 th {
background-color: black;
color: white;
}
</style>
</head>
<body>
<div class="content-wrapper">
<section class="content-header">
<ol class="breadcrumb">
<li><a href="#">Unassign <i class="fa fa-times"></i></a></li>
</ol>
</section>
<br>
<?php include_once "vwLeadshead.php" ; ?>
<section class="content">
<div class="row">
<?php include_once "vwMenu.php" ; ?>
<div class="col-lg-9 col-xs-9">
<div class="box box-primary">
<div class="box-header">
Products
</div>
</div>
</div>
<?php
foreach ($records as $row)
{
?>
<div class="container-fluid">
<div class="row main-content">
<div class="col-xs-9 col-xs-9">
<div class="input-group">
<?php echo form_open('admin/products/search?id='.$row->l_id,['class'=>'form-horizontal panel','method'=>'post']); ?>
<div class="table-responsive">
<table id="example1" class="table table-bordered table-striped">
<tr>
<!-- <th><input class='check_all' type='checkbox' onclick="select_all()"/></th>-->
<thead>
<th>ID</th>
<th>Brand Name</th>
<th>Short Name</th>
<th>Long Description</th>
<th>Cost Price</th>
<th>Selling Price</th>
<th>Supplier</th>
<th>Inventory</th>
<th colspan="2">Action</th>
</thead>
</tr>
<tr>
<!--<td><input type='checkbox' class='case'/></td>-->
<td><span id='snum'>1.</span></td>
<td><input class="form-control autocomplete_txt" type='text' id='p_name_1' name='p_name[]'/></td>
<td><input class="form-control autocomplete_txt" type='text' id='p_short_name_1' name='p_short_name[]'/></td>
<td><input class="form-control autocomplete_txt" type='text' id='p_long_description_1' name='p_long_description[]'/></td>
<td><input class="form-control autocomplete_txt" type='text' id='p_costprice_1' name='p_costprice[]'/> </td>
<td><input class="form-control autocomplete_txt" type='text' id='p_sellingprice_1' name='p_sellingprice[]'/> </td>
<td><input class="form-control autocomplete_txt" type='text' id='p_supplier_1' name='p_supplier[]'/> </td>
<td><input class="form-control autocomplete_txt" type='text' id='p_inventory_1' name='p_inventory[]'/> </td>
<td><a href="">Edit</a> </td>
<td><a href="">Delete</a> </td>
</tr>
</table>
<button type="button" class='btn btn-success addmore'>+ Add More</button>
</div>
</form>
</div>
</div>
</div><!-- /container -->
<?php
}
?>
</form>
</div>
</div>
</div>
</span>
</div>
</div>
</div>
</div>
</section>
</body>
</html>
PHP Code:
MODEL:
[php]function searchproduct($id)
{
$this->db->select('p_name','p_short_name','p_long_description','p_costprice','p_sellingprice');
$this->db->from('product_master');
$this->db->where('u_id' ,$id);
$this->db->where("column LIKE '".strtoupper($name)."%'");
// Also mention table name here
array_push($data, $name);
}
echo json_encode($data);
$query = $this->db->get();
return $query->result();
}
PLZ help me on this i am stuck . thanku in advance.. !!
CONTROLLER:
PHP Code:
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Products extends CI_Controller {
/**
* ark Admin Panel for Codeigniter
* Author: Abhishek R. Kaushik
* downloaded from http://devzone.co.in
*
*/
public function __construct() {
parent::__construct();
$this->load->library('form_validation');
if (!$this->session->userdata('is_admin_login')) {
redirect('admin/home');
}
}
public function index() {
$query = $this->db->get("product_master");
$data['records'] = $query->result();
$data['page']='products';
}
public function search($id)
{
$id=$this->input->get('id');
if($_POST['type'] == 'product_table')
{
$data = array(
$row_num='row_num' => $this->input->post('row_num'),
$name='name' => $this->input->post('name_startsWith')
);
array_push($data, $name);
}
echo json_encode($data);
$this->load->model('admin/insert_products');
$data['records']=$this->insert_products->searchproduct($id);
//return the data in view
$this->load->view('admin/vwProducts', $data);
}
i am stuck please help me with this..thanku so much in advance.