Jump to content

theITvideos

Members
  • Posts

    146
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.theITvideos.com

Profile Information

  • Gender
    Male
  • Location
    Melbourne, Australia.

theITvideos's Achievements

Member

Member (2/5)

0

Reputation

  1. Thank you this code, it worked for me. I would like to ask you one thing... is there a way we can select the result that is displayed i.e. after the search when I click on the search result box it should put the clicked Name in my searchTextbox. As I have shown in the Screenshot I've attached. Please reply. All feedbacks are welcomed. Thank you! [attachment deleted by admin]
  2. Thanks for your message. Yes I am getting the values in the $record variable. Ok I am going to paste the GetResults() function definition and the function call: GetResults() Function definition: function GetResults($query) { $results = array(); $queryLength = strlen($query); // form the sql query string // $query1 = mysql_real_escape_string($query); $username = "root"; $password = ""; $hostname = "localhost"; $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db("AddressBook",$dbhandle) or die("Could not select AddressBook"); $query = mysql_real_escape_string($query); $sql = "SELECT c_name FROM myContact WHERE LEFT(f_name, $queryLength) = '$query'"; // execuite query here, using whatever method you currently use... $res = mysql_query($sql); while($record = mysql_fetch_assoc($res)) { $record = array(); $record['f_name'] = $record['f_name']; // $record['type'] = $record['type']; // $record['content'] = $record['content']; // $record['moreDetailsUrl'] = $record['moreDetailsUrl']; // $record['style'] = ($query == strtolower($record['f_name'])) ? 'expanded' : 'normal'; $record[] = $record; var_dump($record); $results[] = $record[f_name]; } return $results; } I commented out the $record['type'], $record['content'] and $record['moreDetailsUrl '] as I only need the first name and I 'am' getting the first name in the $record variable but when it assigns to the $results[] variable, the f_name value is lost. And here is the function call for GetResults(): $response['results'] = GetResults($query); if (count($response['results']) == 1) { $response['autocompletedQuery'] = $response['results'][0]['f_name']; } Please see the screenshot I have attached here for clear understanding. Thank you. Kindly reply [attachment deleted by admin]
  3. Thank you for your reply. Now I've a debugger and I checked and found out that the $record variable has fName value when it is inside the while loop which is good but when once its values are assigned to the $results[] variable and after comes out the loop, the $results[] variable has no value for the 'fName' index. Do we need to do something inside the while loop near the line: $results[] = $record; Please reply. Thank you.
  4. I am sorry bro but i guess my brains is not in the right place. This is the code I have: function GetResults($query) { $results = array(); $queryLength = strlen($query); // form the sql query string $username = "root"; $password = ""; $hostname = "localhost"; $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db("AddressBook",$dbhandle) or die("Could not select AddressBook"); $query = mysql_real_escape_string($query); $sql = "SELECT fName FROM myContacts WHERE LEFT(fName, $queryLength) = '$query'"; // execuite query here, using whatever method you currently use... $res = mysql_query($sql); while($record = mysql_fetch_assoc($res)) { $record = array(); $record['fName'] = $record['fName']; $record['type'] = $record['type']; $record['content'] = $record['content']; $record['moreDetailsUrl'] = $record['moreDetailsUrl']; $record['style'] = ($query == strtolower($record['fName'])) ? 'expanded' : 'normal'; $record[] = $record; } return $record; } Here is the code. Where shall I fix the $result and $results here. Thank you so much brother!
  5. So how can we fix the $result and $results variable thing. Please reply. Thank you!
  6. Thanks for your reply. yes i did that. And also I am debugging the code to see whats happening under the hood. I noticed even with the proper DB connection, the GetResults() function always returns false. function GetResults($query) { $results = array(); $queryLength = strlen($query); // form the sql query string $username = "root"; $password = ""; $hostname = "localhost"; $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db("AddressBook",$dbhandle) or die("Could not select AddressBook"); $query = mysql_real_escape_string($query); $sql = "SELECT fName FROM myContacts WHERE LEFT(fName, $queryLength) = '$query'"; // execuite query here, using whatever method you currently use... $res = mysql_query($sql); while($record = mysql_fetch_assoc($res)) { $record = array(); $record['fName'] = $record['fName']; $record['type'] = $record['type']; $record['content'] = $record['content']; $record['moreDetailsUrl'] = $record['moreDetailsUrl']; $record['style'] = ($query == strtolower($record['fName'])) ? 'expanded' : 'normal'; $record[] = $record; } return $record; } The value of $record variable is always false. Even though the database connectivity is just fine. There are records in the table for the searched query. By the way... I tried commenting out the 3 lines: $record['type'] = $record['type']; $record['content'] = $record['content']; $record['moreDetailsUrl'] = $record['moreDetailsUrl']; as i don't have the 'type' or 'content' field in the table. what other tweaking shall we do in the getResults() function. Thank you
  7. Ok this is the code that I am using including the database connection in the GetResults() function: function GetResults($query) { $results = array(); $queryLength = strlen($query); // form the sql query string $query = mysql_real_escape_string($query); $username = "root"; $password = ""; $hostname = "localhost"; $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db("AddressBook",$dbhandle) or die("Could not select AddressBook"); $sql = "SELECT firstName FROM myContacts WHERE LEFT(firstName, $queryLength) = '$query'"; // execuite query here, using whatever method you currently use... $res = mysql_query($sql); while($record = mysql_fetch_assoc($res)) { $record = array(); $record['firstName'] = $record['firstName']; $record['type'] = $record['type']; $record['content'] = $record['content']; $record['moreDetailsUrl'] = $record['moreDetailsUrl']; $record['style'] = ($query == strtolower($record['name'])) ? 'expanded' : 'normal'; $record[] = $record; } return $record; } And as I type in the textbox, I get no results. Am I missing anything here in the code. Please reply. Thank you!
  8. Thank you for your reply. Can you please send the code that you are using for testing. Thank you
  9. Yeah I know... I spent 3 hours to make it to work... and it was all trial and error. but it is working now. but just don't know how I made it work. Its website doesn't have a proper instruction for the PC installation. try installation java runtime as this is what I vaguely remember as some prerequisites. Cheers!
  10. Thanks for the reply PFMaBiSmAd, I've removed the GetData() function and removed this function call from the GetResults() parameter list. Now the GetResults() function still uses the variable named $data (which is returned by GetData() function). Sorry brother, this function is little over my head. I am just trying to make it work. I have a simple: database: AddressBook Table: myContacts Field: [firstName],[LastName] where can we embed php select query where it will search for the firstName etc. I thank you so much!
  11. Thanks for the reply seanlim, You can see the code here: http://search-as-you-type.googlecode.com/files/search-as-you-type-v1.2.zip It searches the data smoothly in the textfile that come along with it. Please see the screenshot. Just need to make it search the data in mySQL server. Thank you! [attachment deleted by admin]
  12. Hi there... I found a sample code on the internet that does a good job. Here it is: http://code.google.com/p/search-as-you-type/ http://search-as-you-type.googlecode.com/files/search-as-you-type-v1.2.zip And it works perfectly with a textfile that come along with the source code. Please see the screenshot I got from Google code page. It looks good. Now I just need to hook this to MySql database. Please advice. Thank you! [attachment deleted by admin]
  13. Hi there. I am working on a PHP web form and trying to implement search functionality. It is called Search-as-you-Type. For example, when we do a search in facebook, we get all the pictures and names of the people. in a drop-down like style. I believe this is implemented using some AJAX. Please see the screenshot I've attached. Could any one please share the code or give me some advice on how I can accomplish this. Thank you! All comments and feedbacks are always welcomed [attachment deleted by admin]
  14. Hi there, I am working on a php web form. I have a variable named $isFruit having value of 1 When I do a: print_r($isFruit) It gives me value as 1, which is good. Now I need to pass this php variable into a jquery function: $('document').ready(function() { //I need to get the value of $isFruit variable here } How can pass the php variable into this function. Kindly reply. All comments and feedbacks are always welcomed. Thank you!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.