Welcome Guest, Not a member yet? Register   Sign In
dynamic fetch of data
#1

(This post was last modified: 11-04-2016, 09:39 PM by sheenam.)

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

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&nbsp;<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> 
MODEL
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.. !! 
[/php]

CONTROLLER:
PHP Code:
<?php

if (!defined('BASEPATH'))
 
   exit('No direct script access allowed');

class 
Products extends CI_Controller {

 
   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.
Reply


Messages In This Thread
dynamic fetch of data - by sheenam - 11-04-2016, 05:19 AM
RE: dynamic fetch of data - by dave friend - 11-04-2016, 06:00 AM
RE: dynamic fetch of data - by Wouter60 - 11-04-2016, 06:36 AM
RE: dynamic fetch of data - by sheenam - 11-04-2016, 09:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB