Jump to content

theITvideos

Members
  • Posts

    146
  • Joined

  • Last visited

    Never

Everything posted by theITvideos

  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!
  15. Hi there I am working on PHP form which has an array named: $productOptions. When I do: print_r($productOptions); it returns: Array ( [124] => Array ( [optionId] => 124 [optionName] => acer aspire [optionListId] => 28 [dateCreated] => 2010-11-04 12:48:53 [enabled] => 1 [optionQtyId] => 84 [productId] => 40 [quantity] =>7 ) [114] => Array ( [optionId] => 114 [optionName] => acer fast [optionListId] => 28 [dateCreated] => 2010-11-01 02:04:53 [enabled] => 1 [optionQtyId] => 83 [productId] => 40 [quantity] => 0 ) Now from this Array, I would like to check if the quantity if greater than Zero. so I tried: if (productOptions[quantity] > 0){ echo "blah blah..." } But for getting the quantity, the part: productOptions[quantity] returns nothing. Am I doing this correctly? Please reply. Thank you
  16. Thank you. It was so easy to fix!! I am so happy, no more stress to my eyes. Thank you bro once again!!
  17. Glad to hear from you. So now I have tried my hands on windows scheduler. I can created a simple task that just displays a test msg (just to see if it is working.) Now how do I write a php script that will get the updated xml data from a link i.e: http://mydomain.com/TheUpdatedxmlFile.xml and update the old xml file residing on my localhost. And once I can get the update script, then in the Windows Scheduler I can set it to 'once a day' coz I am allowed to access the new xml file only once in a day. Now i can take care of the scheduling part, it is just the php script (or code) that I need that will automate the process of getting the updated xml file. (Basically to replace the old xml file with the new one from the link) Please reply. Thank you!
  18. Hi there, I am working on a php project on my WAMP server where I have access to XML datafeed from xe.com once a day to get the Exchange rates. This xml datafeed is saved on my localhost as an archived copy. Now I would like to automatically access the fresh xml datafeed file from xe.com once a day and replace (or update) the xml file on my localhost to have the updated information (rates). How can I schedule this task automatically and make php access the updated xml file once a day. All comments and feedbacks are always welcomed Thank you!
  19. Hi there. I am trying to display numbers if they have the numbers like: number_format($price,2) This gives us two decimal places i.e 7.23 Now thats fine, I would like to round the last two decimal places. I would like to make it 7.25, (rounding it from 7.23 to 7.25) Similarly making: 12.44 to 12.45 33.18 to 33.20 52.13 to 52.15 So actually rounding the last two places. Coz obviously customers won't be able to pay 52 dollars 13 cents. So therefore rounding the last cent's (decimal part) making it to 52.15 Thank you. All comments and feedback are welcomed. (d
  20. How sweeet of you. thank you very much! I so very appreciate. It is now working smoothly.
  21. gosh how ignorant of me, i spent a good time on this crazy thing. It was just a tiny smaalll things. Now it works like a charm! Good that you pointed this out! Bravo!!
  22. I pasted the code earlier, here it is again: $euro_countries = array('Albania' || 'Andorra' || 'Germany' || 'Austria' || 'Bulgaria' || 'Croatia' || 'Cyprus' || 'Czech Republic'); if (in_array($txtCountry, $euro_countries)) { echo "You selected European Country"; } elseif($txtCountry == 'USA') { echo "You selected USA"; } else { echo "Unknown"; } But now I figured out a way which is not so efficient but it gives the result: if ($txtCountry == 'Italy' || $txtCountry == 'Germany' || $txtCountry == 'Spain' || $txtCountry == 'Poland' || $txtCountry == 'Sweden' || $txtCountry == 'France') { echo "You selected European Country"; } elseif($txtCountry == 'USA') { echo "You selected USA"; } else { echo "Unknown"; } yeah this works for me, but I guess not so effecient way of doing it. Array thing would've been better. But i guess... as long as it works, it works. What do you think?
  23. Ok I checked, if I only have one element in the array then it compares the European country correctly. If there are more countries in the array i.e $euro_countries = array('Germany', 'Spain', 'Belgium', 'Cyprus', 'Estonia'); then as crazy as it may sound, it just satisfies the condition and says 'it is a European country' even it enter Japan or some other non-european country. On the other hand, it if I just have an array with one element as: $euro_countries = array('Germany'); Now it actually checks if I entered a european country when I have only one element in the array. Why it always meets the condition to true with multiple elements of european countries in the array even if I type non-european country. Is it something to do with the array list here?
  24. Thanks for the reply. This is very strange. I type the code exactly has you mentioned. i.e. creating an array of countries. I typed: $euro_countries = array('Albania' || 'Andorra' || 'Germany' || 'Austria' || 'Bulgaria' || 'Croatia' || 'Cyprus' || 'Czech Republic'); if (in_array($txtCountry, $euro_countries)) { echo "You selected European Country"; } elseif($txtCountry == 'USA') { echo "You selected USA"; } else { echo "Unknown"; } The control always still goes to the first condition, even if I type a non-European country like when I type USA. It says 'You selected European Country' Then I checked to see what shows in the $euro_countries Array. I did the print_r() print_r($euro_countries); I get: Array ( [0] => 1 ) Are we missing something here. Cheers!
×
×
  • 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.