TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 02-04-2012, 08:40 AM   #1 (permalink)
The Wanderer
 
arpittailang's Avatar
 
Join Date: Feb 2012
Posts: 6
Thanks: 2
arpittailang is on a distinguished road
Default Predictive Search using PHP on Wordpress Theme

Hello, I am customizing a wordpress theme. It contains a Location Search that shows locations as drop down menu. But i want to show predictive search such as when user types "NE" it shows "New York, united States". It is also called autocomplete. I want a solution for a it from beginning as i am completely newbie.

The Theme has admin panel where an option allow to add locations, and these location are saved in database. I just need these locations to show on predictive search.
Here is the code that calls the location databsae :


PHP Code:
div class="search_row clearfix">
            <label> <?php _e(SEARCH_LOCATION_TEXT); ?> : </label>   
                <select name="srch_location" id="srch_location" onchange="" class="fl select">
                 <option value=""><?php _e(SEARCH_ALL_LOCATION_TEXT); ?> </option>
                  <?php echo get_location_dl($_REQUEST['srch_location']);?>
                <?php //echo get_category_dropdown_options(get_cat_id_from_name(get_option('ptthemes_locationcategory')),$_REQUEST['srch_location']);?>
               </select>
I think "srch_location" is the location where all these location saved. How can i show these to predictive search. Please answer in steps so i can understand because i dont know php very well.
Also it would be good if yoou include the easy jQuery or AJAX Script that does the job and a guide how to implement in the code.

Update: How to call the location where country list is saved using php? for example i am using this code to get the location to be appear on the predictive search :
PHP Code:
onchange="<?php echo get_location_dl($_REQUEST['srch_location']);?>"
but its not working but I am 100% sure and tested that this code is working well when i code dropdown for location textbox. I just need to work as well for predictive search.

Thank you very much.

Last edited by arpittailang : 02-04-2012 at 10:13 AM. Reason: i got something new to ask
arpittailang is offline  
Reply With Quote
Old 02-04-2012, 11:24 AM   #2 (permalink)
The Acquainted
 
Join Date: Nov 2009
Location: nr Stratford-Upon-Avon
Posts: 137
Thanks: 3
maeltar is on a distinguished road
Default

For predictive autocomplete, you need to be looking at jQuery autocomplete... If as you are saying a complete newbie to php, you may be biting off more than you can chew for a first hack. However, do not let this put you off, rather than do the code for you, the best way to learn is to try, then post questions when you get stuck, there are 100's of tutorials out there..

A Good placed to start is : HERE
__________________
Thanks... Simon

Sex, Drugs & Linux Rules
Send a message via MSN to maeltar
maeltar is offline  
Reply With Quote
The Following User Says Thank You to maeltar For This Useful Post:
arpittailang (02-04-2012)
Old 02-04-2012, 11:33 AM   #3 (permalink)
The Wanderer
 
arpittailang's Avatar
 
Join Date: Feb 2012
Posts: 6
Thanks: 2
arpittailang is on a distinguished road
Default

Thank you very much for your reply.
I am stuck, its true and i posted here after searching on google a lot.
I am following this tutorial :
http://www.script-tutorials.com/auto...mysql-and-xml/

All details i already posted and eager if any one helps.
In the tutorial, the locations are taken from database, whereas i want to show the locations using
"srch_location" (PHP Code Required)
arpittailang is offline  
Reply With Quote
Old 02-04-2012, 11:39 AM   #4 (permalink)
The Wanderer
 
arpittailang's Avatar
 
Join Date: Feb 2012
Posts: 6
Thanks: 2
arpittailang is on a distinguished road
Default

Thank you very much for your reply.
I am stuck, its true and i posted here after searching on google a lot.
I am following this tutorial :
http://www.script-tutorials.com/auto...mysql-and-xml/

All details i already posted and eager if any one helps.
In the tutorial, the locations are taken from database, whereas i want to show the locations using
"srch_location" (PHP Code Required)
arpittailang is offline  
Reply With Quote
Old 02-04-2012, 11:39 AM   #5 (permalink)
The Wanderer
 
Join Date: May 2010
Posts: 19
Thanks: 1
core1024 is on a distinguished road
Default

According to this source code the function get_location_dl outputs HTML. The parameter ($_REQUEST['srch_location']) is just "remembered" selected option. As you can see srch_location is the name of the "select" element and element of the array $_REQUEST.
Have you tried to check the source of the page with this code?
If you're using this functions you could easily use jQuery autocomplete with code like this:

HTML Code:
<input name="srch_location" id="srch_location" value="<?php echo htmlspecialchars($_REQUEST['srch_location']); ?>"/>
<script>
	$(function() {

		$( "#srch_location" ).autocomplete({
			source: ["<?php echo str_replace(',','","',get_location_srch_params())?>"]
		});
	});
</script>
core1024 is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Beginner Guide #1 Hershey Absolute Beginners 1 11-07-2011 10:42 PM
search for a string through multiple php documents jac4b Absolute Beginners 5 05-19-2010 05:36 PM
10 PHP Myths Dispelled Wildhoney General 9 06-15-2009 06:55 AM
Search Engine Friendly URLs in PHP Without Mod_Rewrite ETbyrne General 6 12-09-2008 10:50 PM
PDF Full text search using PHP code_junkie Advanced PHP Programming 1 09-18-2008 07:59 PM


All times are GMT. The time now is 12:30 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design