Gremlyn1
09-08-2009, 06:46 PM
I am working on an FAQ section for my work's customer service portal and am wondering what method would be more efficiency. In my database I have a table of products, and each product has a field with a string of numbers in it that corresponds to the id number of the FAQ. These id's are arranged in the order I want them displayed. For those visual people:
product | faq_order
Product 1 | 5,6,4,3
Product 2 | 2,9,6
Product 3 | 1,8,6,7
Also, in the FAQ table, each currently has a field that relates it to the product(s) it applies to (using a product id).
I need to display the FAQ's in that order on the admin side and then all un-ordered FAQs (not all are necessarily shown to the user) so that they can add them to the shown FAQs if needed. I can conceive of two ways to do that...
#1 is to explode 'faq_order' into an array, and use a foreach loop to go through and make a mysql call for the approrpiate FAQ id number, then output the appropriate info until there are no more. Then tack on the rest of the unordered FAQs with a call that pulls the unordered FAQs that have the product id and display those.
#2 is to pull all FAQs related to the selected product into a multidimensional array (using the yet-to-be-needed field in the FAQ table I mentioned above), and then pick out the component arrays from inside the master array as needed in order, again using an explode of the 'faq_order'.
I'm sure there are other ways, if you have a better one, please let me know, otherwise what would be more efficient of my two options? There will be maybe 10-20 FAQ's pulled at a time most likely.
product | faq_order
Product 1 | 5,6,4,3
Product 2 | 2,9,6
Product 3 | 1,8,6,7
Also, in the FAQ table, each currently has a field that relates it to the product(s) it applies to (using a product id).
I need to display the FAQ's in that order on the admin side and then all un-ordered FAQs (not all are necessarily shown to the user) so that they can add them to the shown FAQs if needed. I can conceive of two ways to do that...
#1 is to explode 'faq_order' into an array, and use a foreach loop to go through and make a mysql call for the approrpiate FAQ id number, then output the appropriate info until there are no more. Then tack on the rest of the unordered FAQs with a call that pulls the unordered FAQs that have the product id and display those.
#2 is to pull all FAQs related to the selected product into a multidimensional array (using the yet-to-be-needed field in the FAQ table I mentioned above), and then pick out the component arrays from inside the master array as needed in order, again using an explode of the 'faq_order'.
I'm sure there are other ways, if you have a better one, please let me know, otherwise what would be more efficient of my two options? There will be maybe 10-20 FAQ's pulled at a time most likely.