grk101 Posted May 30, 2009 Share Posted May 30, 2009 So i am trying to help my buddy with his website here. but we are a both a bit lost. i'll give you guys exaples cause i think its probalby the only way i even understand it. Lets say you search his website for the term " pizza " you'll have the term $search = 'pizza'; what he wants to do is on the side column, have a list of words that tie with the word pizza.. So example: Mushrooms, pine apple, bacon, cheese: is this possible? I thought maybe doing a switch case php would work.. i might be work.. <?php $selected_term = $_GET['pizza'] ; switch ($selected_term) { case 1: include("toppings1.php"); break; case 2: include("blah.php"); break; } ?> I am probably wrong now that i look at it, but if anyone could help? thanks Quote Link to comment https://forums.phpfreaks.com/topic/160233-php-search-phrase-to-populate-side-columns-with-terms/ Share on other sites More sharing options...
Michdd Posted May 30, 2009 Share Posted May 30, 2009 I guess you could do something like that.. But then you'd have to hard-code what to include for each specific search term? Quote Link to comment https://forums.phpfreaks.com/topic/160233-php-search-phrase-to-populate-side-columns-with-terms/#findComment-845508 Share on other sites More sharing options...
Hybride Posted May 30, 2009 Share Posted May 30, 2009 Unless you want to use a database, I'd go for arrays. $pizza = array("topping" => "mushrooms", "bacon", "cheese", "crust" => "cheese","plain"); etc. Quote Link to comment https://forums.phpfreaks.com/topic/160233-php-search-phrase-to-populate-side-columns-with-terms/#findComment-845511 Share on other sites More sharing options...
.josh Posted May 30, 2009 Share Posted May 30, 2009 coming up with a system to link similar stuff like that is not really going to be the hard part. You can do something as simple as have a table of words with ids and a list of ids of all other words you want to be associated with it. The hard part is mapping out what words relate to each other. There is no "set in stone" list. Your example links those other words to pizza because they happen to be toppings on a pizza. Well that's an arbitrary link. You will not, for instance, see mushroom show up on a list of words for pizza in a standard thesaurus (or visa versa). Quote Link to comment https://forums.phpfreaks.com/topic/160233-php-search-phrase-to-populate-side-columns-with-terms/#findComment-845554 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.