[ create a new paste ] login | about

Link: http://codepad.org/Tewep1Jl    [ raw code | output | fork ]

PHP, pasted on Aug 30:
<table width="608">
	<caption>
	DANH SÁCH KHÁCH HÀNG<br>
	<input type="search" id="name" onKeyUp="callAjax()" placeholder="Nhập tên thành viên...">
	</caption>
	<tr>
	<th width="30" scope="col">ID</th>
	<th width="150" scope="col">Tên</th>
	<th width="87" scope="col">Email</th>
	<th width="80" scope="col">Giới tính</th>
	<th width="100" scope="col">Quản lý đơn hàng</th>
	<!--<th width="136" scope="col"><a href="?mod=dep_add" class="dep_add"><img src="images/Add1.png">Thêm</a></th>-->
	</tr>
	<tbody class="list">
	  <?php
		$i=0;
		$sql="SELECT * FROM `nn_user` ORDER BY `id` desc ";
		$rs=mysqli_query($link,$sql);
		while($r=mysqli_fetch_assoc($rs))
		{
	  ?>	  
		  <tr>
			<td align="center"><?php echo $r['id'] ?></td>
			<td align="center"><?php echo $r['name'] ?></td>
			<td align="center"><?php echo $r['email'] ?></td>
			<td align="center"><?php if($r['gender']==1) echo "Nam"; else echo "Nữ"; ?></td>
			<td align="center"><a href='?mod=dep_upd&id=<?php echo $r['id']?>'>Xem chi tiết</a></td>
		  </tr>		  
	  <?php
		}
	  ?>
	</tbody>
</table>
<script>
	function callAjax(){
			$.ajax({
				url: 'searchcustom_ajax.php',
				type: 'GET',
				data: { name: $('#name').val(),},
				success: function(data){
					//alert(data);
					$('.list').html(data);
				}
			});
	}
</script>

=========================================================
===================File xử lý load dữ liệu (searchcustom_ajax.php)=======================
=========================================================
<?php
	require('db.php');
	$name=$_GET['name'];
	$sql="select * from `nn_user` where `name` like '%$name%' or `email` like '%$name%' or `mobile` like '%$name%'";
	$rs=mysqli_query($link,$sql);
	if(mysqli_num_rows($rs)>0)
	{
		while($r=mysqli_fetch_assoc($rs))
		{	
?>		  <tr>
			<td align="center"><?php echo $r['id'] ?></td>
			<td align="center"><?php echo $r['name'] ?></td>
			<td align="center"><?php echo $r['email'] ?></td>
			<td align="center"><?php if($r['gender']==1) echo "Nam"; else echo "Nữ"; ?></td>
			<td align="center"><a href='?mod=dep_upd&id=<?php echo $r['id']?>'>Xem chi tiết</a></td>
		  </tr>	
<?php
		}
	}
?>


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<table width="608">
	<caption>
	DANH SÁCH KHÁCH HÀNG<br>
	<input type="search" id="name" onKeyUp="callAjax()" placeholder="Nhập tên thành viên...">
	</caption>
	<tr>
	<th width="30" scope="col">ID</th>
	<th width="150" scope="col">Tên</th>
	<th width="87" scope="col">Email</th>
	<th width="80" scope="col">Giới tính</th>
	<th width="100" scope="col">Quản lý đơn hàng</th>
	<!--<th width="136" scope="col"><a href="?mod=dep_add" class="dep_add"><img src="images/Add1.png">Thêm</a></th>-->
	</tr>
	<tbody class="list">
	  
Fatal error: Call to undefined function mysqli_query() on line 18


Create a new paste based on this one


Comments: