Ich habe ein Sucheingabefeld auf meiner Seite. Zur Zeit zeige ich Daten aus der Datenbank erfolgreich in einer Tabelle an (id = "table_userinfo"). Jetzt möchte ich die Live-Suche auch in meine Tabelle (id = "table_userinfo") einfügen. Ich benutze PHP Codeigniter. in meinem user_model ich habe:Anzeige von Daten in einer Tabelle nach ihrer ID nach erfolgreichem AJAX-Aufruf
function search_userInfo($keyword)
{
$this->db->like('DeviceName',$keyword);
$this->db->or_like('RegistrationDateTime',$keyword);
$this->db->or_like('LastUpdateDateTime',$keyword);
$this->db->or_like('AppVersion ',$keyword);
$this->db->or_like('iOSVersion',$keyword);
$this->db->or_like('DeviceDID',$keyword);
$this->db->or_like('DeviceToken',$keyword);
$query = $this->db->get('userinfo');
if($query)
{
return $query->result();
}
else
{
return NULL;
}
}
in meinem login_controller:
function displayDatabase()
{
$data['tableInfo']=$this->user_model->fetchData();
$this->load->view('adminPanel_view',$data);
}
function search()
{
$search=$this->input->post('searchString');
$data['tableInfo']=$this->user_model->search_userInfo($search);
}
in meiner adminPanel_view Seite, ich habe:
<script>
$('#search').keyup(function(){
var input_data = {searchString: $('#search').val() };
//console.log(input_data);
$.ajax({
type:"POST",
url:base_url+'index.php/login_controller/search',
data:input_data,
success:function(data){
if(data.length>0)
{
console.log(data);
}
}
});
});
</script>
<table class="table table-bordered table-hover table-full-width" id="table_userinfo">
<thead>
<tr>
<th>Serial No.</th>
<th class="hidden-xs">Device Name</th>
<th>Device Type</th>
<th>RegistrationDateTime </th>
<th>LastUpdateTime</th>
<th>LastPushNotificationSent</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php //print_r ($tableInfo);exit;?>
<?php $no=0;?>
<?php foreach($tableInfo as $r): ?>
<tr>
<td><?php echo $no ?></td>
<td><?php echo $r->DeviceName ?></td>
<td><?php echo $r->DeviceType ?></td>
<td><?php echo $r->RegistrationDateTime ?></td>
<td><?php echo $r->LastUpdateDateTime ?></td>
<td><?php echo $r->LastPushNotificationSent ?></td>
<td><?php echo "Actions" ?></td>
</tr>
<?php $no+=1;?>
<?php endforeach; ?>
</tbody>
</table>
dies ist die Suche Bar, die ich zusätzlich t verwende o diese Tabelle
<div id="" class="dataTables_filter">
<label>
<input placeholder="Search" class="form-control input-sm" aria-controls="sample_1" type="text" id="search" name="search_userinfo">
</label>
</div>
Wie kann ich die Daten anzeigen, die ich durch die Ajax-Aufruf immer bin und zeigen es in der Tabelle (id = "search_userinfo).
'echo' benötigt wird. – Tpojka
Ja, Echo statt Rückkehr – kunicmarko20