I want to make one search box which display list of matched records from database related to which we have type in our box, I have Use Jquery's Auto Complete. That's OK, but I want to select records from my database Table instead manually give it in var availableTags. I want to get records from DB in var availableTags in following code..
here is my code with Smarty Templates.....
My Html:(searchh.tpl)
{block name=head}
<title>Untitled Document</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
}
$(function() {
var availableTags = [
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: availableTags
});
});
</script>
{/block}
{block name=body}
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags" />
</div>
{/block}
My php :(searchh.php)
<?php
include("include/config.inc.php");
$pArray = 0;
$search = isset($_POST['search']) && ($_POST["search"] != "") ? $_POST['search']:'';
if($search != '')
{
$query="select * from party where partyName like '%$search%' ";
$result = mysql_query($query);
$pArray = array();
$n = 0;
while ($row = mysql_fetch_array($result))
{
$pArray[$n]['partyId'] = $row['partyId'];
$pArray[$n]['partyName'] = $row['partyName'];
$n++;
}
}
include("./bottom.php");
$smarty->assign("search",$search);
$smarty->assign("pArray",$pArray);
$smarty->display('searchh.tpl');
?>
If Anybody can help, It will very grateful to me. Thanks..