Hi guys,
Really need some help on this tricky problem. Basically, I have a search box which has an auto suggest feature (jquery) which runs through a list of stores (mysql database query). Once the user types a key in the search box, a list of stores matching that letter appears. Clicking the resulting store name from the dropdown box enters the store name into the search box, ready to be searched. The auto suggest feature of the search box works fine except if the url is a rewritten one with a variable passed through it. I can still type manually into the search box but really want the auto suggest to do the hard work.
This url won’t work - http://www.mywebsite.co.uk/store/store_name
however, if I manually change the url to the native querystring it works
http://mywebsite.co.uk/store.php?name=store_name
Anyone have any suggestions? Btw, I get no errors.
Here’s the code for the search box
<div id="search_container">
<form id="search" action="" method="post" >
<input name="find" type="text" class="search" /><input type="submit" value="submit">
</form>
</div>
<div id="suggestbox">
<div class="dropdown">
<ul class="result"></ul>
</div>
</div>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="search.js"></script>
and here’s the code for the search.js script
$(document).ready(function() {
$('.search').keyup(function() {
var search_term = $(this).attr('value');
$.post('result.php', {search_term:search_term}, function(data) {
$('.result').html(data);
$('.result li').click(function() {
var result_value = $(this).text();
$('.search').attr('value', result_value);
$('.result').html('');
});
});*/
});
});
finally here’s the code for the result.php page
<?php
include ('inc/functions.php');
connectdata ();
if (isset($_POST['search_term']) == true && empty($_POST['search_term']) == false) {
$findit = mysql_real_escape_string($_POST['search_term']);
$query = mysql_query("SELECT store FROM stores WHERE store_name LIKE '$findit%' ORDER BY RAND() LIMIT 10");
while (($row = mysql_fetch_array($query)) !== false) {
echo '<li>', $row['store_name'], '</li>';
}
}
?>
Any help would be great, really puzzling me as to why it won’t work on some pages but is fine on others