Geo My WP - Create Dropdown Menu Search Input - php

I have learned a lot from this forum and finally I am in need of specific help. If someone can help me solve this, you will have my eternal gratitude.
Framework:
Wordpress site that has Buddypress(BP) and GEO My WP installed. Each user has a certain set of BP profile fields that Geo My WP uses to search through and return the results.
Goal: On the Geo My WP search form, I wish to have a dropdown list that a user can select one item; for example "Hockey". This selected item is then used to search through two (2) different BP xprofile fields (eg: "Main Sports" & "Casual Sports"). These two BP xprofile fields will be populated by the admin and they will both be a text line with single terms separated by a comma; for example "Basketball, Football, Soccer, Hockey" etc.
If the user selected term matches a term in either of the two BP xprofile fields, Geo My WP will return the BP profile in the search results.
Problem: I can't figure out how to do this. If both BP xprofile fields are selected to search through in Geo My WP settings, then both show up on the search form. I need it to be only one input in the search field.
I have run out of ideas on manipulating the code and would appreciate some fresh eyes on this problem.
Many thanks,
MM.

You might try doing some JS changes to your form. That would not be perfect, but worked at least in my case. Here's an example of what I mean.
jQuery('#gmw-address-1').remove();
jQuery('#gmw-address-field-wrapper-1').prepend('*');
In your case
You'd need to bind two events: documentReady and change for the select you will create.
on documentReady
get values from selects you want to join together
replace selects with hiden fields
create select combining those two you've just replaced
on change
check chosen value
match it with plausible values to determine witch select it belongs to
update the hidden field you matched in pt. 2 with value from pt.1

Related

Add or Remove Dynamic Dependent Select Box data from two mysql tables using jQuery with PHP Ajax

I need complete sample code to Add or Remove Dynamic Dependent Select Box data from two mysql tables using jQuery with PHP Ajax
Dependent select data should be come these below tables. And should be add and remove button to add row.
Category
Sub Category
Below is sample data, but in this, dependent select data coming from only one mysql table.
https://www.webslesson.info/2019/09/add-or-remove-dynamic-dependent-select-box-using-jquery-with-php-ajax.html
Can any provide me sample demo with source code ?
Please this sample image
Please see this image, There are three tables, (1) Items, (2) Category, (3) Sub Category, I need same like this, but data should come from Category table and sub category table in dependent select boxes. And this is multi dynamic row. Can you give me all demo code, becuase I do not know about Jave,Ajax and jQuery.
Below is sample demo and source code weblink, But in this sample, He is getting data from only one table for both dependent boxes category and sub category. Data should be come from two tables both dependent boxes.
enter link description here
I hope you understand what I required.

populating dropdownlist based on the condition when you click on add button in phpgrid

I am using phpgrid in my project and i wanted to see a dropdownlist to be populated based on the condition.
When i click on the add buttoon in phpgrid, it will allow me to select the Country and based on the country selected, the dropdownlist to be generated which belonging to the selected country.
In my MySQL database i have a location tables separated with parent and child columns and i can able to see the proper result in mysql views. The same thing i wanted to implement with phpgrid.
Ref: http://phpgrid.com/
Have you read http://phpgrid.com/example/nested-dropdown/ ? Seems what you are looking for.

MySQL fields in URL

Is there a way to call field rows in a URL without using the column name??
So I currently have a posting site where users can select category or subcategories of choice from drop downs, how it's currently setup my site outputs links to the categories chosen such as..
topics.php?category=Food&sub_cat=Pies
topics.php?sub_cat=Pies
This allows users to go to either one of the links, or both
topics.php?category=Food&sub_cat=Pies
To give more functionality I am looking at adding textboxes instead of drop downs, the problem is users will more than likely enter the data in different boxes than other users, ie.
User 1. catbox: Food subcatbox: Pies
User 2. catbox: Pies subcatbox: Food
So in this case my current URL system won't return accurate results, so my question is would there be a way where "category" or "subcategory" could be replaced and just put the results together without them being listed in 2-5 different fields therefore not returning all the results that = to that value? "food" or "pie" in this example.
topics.php?xxx=Food&xxx=Pies
or
topics.php?xxx=Pies&xxx=Food
Looking at So homepage if you click "php" it will put php in the URL, click mysql and it will put "php+mysql" that sort of thing.
you can use parent child method in your database.your table would be like this
id - parent_id - category_name - depth
when you want to insert a data to your table it's depth will be one plus it's parent depth
when someone post to your page you first take query witch of the inputs has most depth then that will be your subcategory.
Calling field rows via parameters in your URL may be a very bad idea. It's a perfect way to allow a massive SQL injection attack. So, the answer is probably "yes, but HOLY MOLY PLEASE DON'T!"
Now it may be that your code is parsing these out on the back end and protecting them via any of a variety of methods, I can't tell from the amount of code posted.

Database Schema For Populating Select Lists with PHP/MySQL

I have a two part question with no code to show, but i hope you can help:
Essentially, i have a website which lets businesses create a profile for themselves (original table schema here).
Now within the site I want a form with three select lists in it: the first select list is for business catagory/tag - I have managed to create a query which will return entries from my main business registration table by using a Toxi solution.
However i also want a second select list with countries or regions, and a third select list with states/counties which will load automatically BASED on the selection from the Country select list.
Then naturally, on submitting the form, i want to return the results to the visitor.
So, apart from wondering how to achieve this much in PHP/MySQL, i have a more fundamental question about whether to set up the countries/states 'tagging' or 'catagories' field as another Toxi solution, or if there's a better way to do it. For instance, should i/can i just create seperate tables to populate the select lists with states/counties based on country selection, and have the actual country and state fields that a business selects on registration, stored within my main business table, and just match the strings when the user hits submit, in order to reduce queries to MySql and improve speed?
As always, your advice and help is greatly appreciated.
Thanks
Dan
Think about the "full name" of a state (or whatever political division is one level narrower than "country"). In the Americas, here are some "full names" of states.
California, US
Connecticut, US
Ontario, CA
Sonora, MX
Lara, VE
Base your lists on a two-column table of the full names of states.
ISO country codes
The critical point is that your selection lists shouldn't allow values like "Alabama, MX" or "Sonora, US".

Golf Round Recorder PHP, MYSQL, AJAX

I am developing a golf website where users can track their rounds and handicaps and have a few different ideas on how the user inputs their round information. I have a table for courses and a corresponding row in another table (scorecards) that has all the courses scorecard information. The 'round recorder' is a three part form (basic, scorecard, preferences) and in the basic part of the form the course input is a autocomplete field. I was wondering if there was a way that I could use a chained select from a autocomplete field.
e.x. Course1(has 18 holes) -> List Front Nine/Back Nine (user selects one or both and than loads that scorecard from database)
Any advice or suggestions would be greatly appreciated. Thanks in advance.
This isn't the most specific answer, but basically you want to capture the "change" event of the select box. For the front or back nine, you would check whether "front", "back", or both was checked and update that accordingly within load_scorecard().
<select onchange="load_scorecard(this.value);">
and then the JS:
function load_scorecard(scorecard_id) {
// Obtain data from a database or preloaded array
// Then, update the page with the scorecard.
}

Categories