Welcome Guest, Not a member yet? Register   Sign In
Database LiveSearch
#1

[eluser]joe.afusco[/eluser]
Pretty new to PHP and CodeIgniter. Not sure that I am even doing this the best way possible. Attempting to live search a database, so when a user begins typing in a search field, the results populate in a div. Followed this video:

http://www.youtube.com/watch?v=mSAbp_4ACaw

Here is what I have so far. My search is calling the javascript function:

Code:
<input type="text" class="search-query" placeholder="Search" />

Although, it seems when I wrap code tags, it hides my onkeyup event. But it is there.

Javascript function:

Code:
function getSearchResults(value) {
   $.post("getSearchResults.php",{partialSearch:value}, function(data){
    $("#search_results".html(data));
   });
  }

And the php file that searches:

Code:
<?php

$partialSearch = $_POST['partialSearch'];

$results = $this->db->query("SELECT email_address FROM users WHERE email_address LIKE '%$partialSearch%'");

while ($resultsArray = mysql_fetch_array($results)) {
echo "<div>".$resultsArray['email_address']."</div>";
}


?&gt;

Can't seem to spot the error. Note, these are all 3 on separate files, not sure if that is the issue. Search is in navigation.php view, which is loaded on every page, the javascript is in the main user view which loads the navigation, and the php is a separate file all together, in the same directory as these views. Any help on this, or any better way of trying to accomplish the task would be much appreciated.



Messages In This Thread
Database LiveSearch - by El Forum - 05-30-2012, 06:22 AM
Database LiveSearch - by El Forum - 05-30-2012, 06:52 AM
Database LiveSearch - by El Forum - 05-30-2012, 06:57 AM
Database LiveSearch - by El Forum - 05-30-2012, 07:00 AM
Database LiveSearch - by El Forum - 05-30-2012, 07:00 AM
Database LiveSearch - by El Forum - 05-30-2012, 07:01 AM
Database LiveSearch - by El Forum - 05-30-2012, 07:09 AM
Database LiveSearch - by El Forum - 05-30-2012, 07:13 AM
Database LiveSearch - by El Forum - 05-30-2012, 07:34 AM
Database LiveSearch - by El Forum - 05-30-2012, 07:40 AM
Database LiveSearch - by El Forum - 05-30-2012, 07:57 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:10 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:11 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:13 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:17 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:20 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:22 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:27 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:29 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:30 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:32 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:33 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:36 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:39 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:41 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:42 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:43 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:43 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:45 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:46 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:49 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:57 AM
Database LiveSearch - by El Forum - 05-30-2012, 08:59 AM
Database LiveSearch - by El Forum - 05-30-2012, 09:03 AM
Database LiveSearch - by El Forum - 05-30-2012, 09:08 AM
Database LiveSearch - by El Forum - 05-30-2012, 09:16 AM
Database LiveSearch - by El Forum - 05-30-2012, 09:19 AM
Database LiveSearch - by El Forum - 05-30-2012, 09:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB