Using tags via URL to trigger queries…
-
First of all, please don’t get on me for not using WordPress syntax to query a database. In my defense, I’m using a non-WP table. ??
I’m wanting to take the tag or search slug passed via a URL to query a database to create a list of players. Those slugs will either be a school name or a player’s name, but no matter which, I need the school’s name to produce my list.
If it’s a school’s name, it’s easy. If it’s a player’s name how do I get the school name for query?
Do I use a sub/nested query?
Such as
SELECT school
FROM
(SELECT nameFirst,nameLast,feet,inches,city,school,grade FROM a_players
WHERE school = ‘”.$wp_searchSlug.”‘
AND grade>=’20′”;)Something like that?
Below is what I’m using now. Obviously, if it’s player name, it produces a blank result.
$tag = single_tag_title("", false); // the false is a display setting for WP template tags $wp_searchSlug = get_search_query(); if ($wp_searchSlug != "") { $query = "SELECT nameFirst,nameLast,feet,inches,city,school,grade FROM a_players WHERE school = '".$wp_searchSlug."' AND grade>='20'"; } else { $query = "SELECT nameFirst,nameLast,feet,inches,city,school,grade FROM a_players WHERE school = '".$tag."' AND grade>='20'"; }
- The topic ‘Using tags via URL to trigger queries…’ is closed to new replies.