Searching with serialized id's |
When the user types in the search PHP it should find the questions that have category id of 1
I store my category id in a column in question called "tags" it's serialized of couse because the user may have chosen multiple tags / categories. The category table name is category and columns "category_id" "name" "status" a:2:{i:0;s:1:"1";i:1;s:1:"4";} I can search for questions fine but cannot search if it is a category they are searching for. Any idea's and examples thanks for your time PHP Code: public function get_questions($search) { Controller PHP Code: <?php
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
You need a one-to-many relationship with two tables, one for questions, one for categories/tags. Then use a table join to select the tags based on the question id.
So your DB might be for example: Code: question
(10-25-2016, 05:03 PM)JayAdra Wrote: You need a one-to-many relationship with two tables, one for questions, one for categories/tags. Then use a table join to select the tags based on the question id. Thank you I will look in to it tonight. Am trying to get bit more better in my coding.
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
|
Welcome Guest, Not a member yet? Register Sign In |