hi guys im new in codeigniter i need a tutorial on how can i convert my
autocomplete php code in codeigniter
Here is my code this is my way of auto suggest it is working my problem is
how can i convert this to codeigniter with my javascripts how can i
separate them into MVC any ideas or help thanks in advance
INDEx.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Auto Complete Input box</title>
<link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.autocomplete.js"></script>
<script>
$(document).ready(function(){
$("#tag").autocomplete("autocomplete.php", {
selectFirst: true
});
});
</script>
</head>
<body>
<label>Tag:</label>
<input name="tag" type="text" id="tag" size="20"/>
</body>
</html>
autocomplete.php
<?php
$q=$_GET['q'];
$my_data=mysql_real_escape_string($q);
$mysqli=mysqli_connect('192.168.128.30','h2mshop','h2mshop','h2mshop')
or die("Database Error");
$sql="SELECT * FROM items WHERE itemcode LIKE '%$my_data%' ORDER BY
itemcode";
$result = mysqli_query($mysqli,$sql) or die(mysqli_error());
if($result)
{
while($row=mysqli_fetch_array($result))
{
echo $row['itemcode']."\n";
}
}
?>
No comments:
Post a Comment