| | |
user preferences
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Feb 2008
Posts: 5
Reputation:
Solved Threads: 1
hello reader..
i am developing a website.
One of the web's page is PRODUCT page where user can view, or purchase the item. There are 3 categories under PRODUCT which are; pet, gardening and food..
I'd like to implement user preferences in this page. User will pick its preferences via check boxes. For example, if she chose pet and gardening, any item available in mysql about pet & gardening will appear in the user's PRODUCT page. Meanwhile, if the user isn't a registered user, products of food/ pet/ gardening will appear randomly.
The questions are:
1) HOw should i create the table? Stuff all user info and preferences in USER table or make them in chuncks. 4 tables( user, pet, food, gardening)
2) overall, how to code the idea? i browsed tru hundreds of forums, but couldn't find any that suits the idea
Pls help. TQ
i am developing a website.
One of the web's page is PRODUCT page where user can view, or purchase the item. There are 3 categories under PRODUCT which are; pet, gardening and food..
I'd like to implement user preferences in this page. User will pick its preferences via check boxes. For example, if she chose pet and gardening, any item available in mysql about pet & gardening will appear in the user's PRODUCT page. Meanwhile, if the user isn't a registered user, products of food/ pet/ gardening will appear randomly.
The questions are:
1) HOw should i create the table? Stuff all user info and preferences in USER table or make them in chuncks. 4 tables( user, pet, food, gardening)
2) overall, how to code the idea? i browsed tru hundreds of forums, but couldn't find any that suits the idea
Pls help. TQ
I would have a single table, called user_pref, which would have the columns user_id, product_type_id, both of which would form the primary key for the table. If the user selects pets as a preferred option, add their user id and the pets category's id to the table. If the user then also selects the gardening category, add that to the table to.
When you display the items, check the table for preferences and if there is at least one row for their user id only display items in the categories listed, otherwise display items from all categories.
Hope this helps
darkagn
When you display the items, check the table for preferences and if there is at least one row for their user id only display items in the categories listed, otherwise display items from all categories.
Hope this helps

darkagn
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend. I would suggest also making a dedicated table for the user preferences. However I would suggest making a column for each preference. Eg. user_id, gardening, pet, food.
As for the pets, gardening and food tables, it is a good idea to make as many tables in your database as possable, this means you wont overstress a single table.
So in a sense, when the user sellects pet and food you will check the table for the users ID if there is already and ID then edit that row else make a new one. The idea is add a 1 into the column the chose, in the instance it is pet and food,
This will make the row look like this:
ID --- Pet --- Gardening --- Food
----------------------------------------
984 1 0 1
======================
So if they have a 1 in any of the topics then you will retreive the rows from the specified tables.
This is the most ligical way to my knowledge.
As for the pets, gardening and food tables, it is a good idea to make as many tables in your database as possable, this means you wont overstress a single table.
So in a sense, when the user sellects pet and food you will check the table for the users ID if there is already and ID then edit that row else make a new one. The idea is add a 1 into the column the chose, in the instance it is pet and food,
This will make the row look like this:
ID --- Pet --- Gardening --- Food
----------------------------------------
984 1 0 1
======================
So if they have a 1 in any of the topics then you will retreive the rows from the specified tables.
This is the most ligical way to my knowledge.
Posts should be like mini-skirts, long enough to cover enough, but not too long that you cover too much.
My Liveperson: http://liveperson.com/josh-connerty/
My Liveperson: http://liveperson.com/josh-connerty/
![]() |
Similar Threads
- Matching user preferences (MS SQL)
- "unable to load user Preferences" (Windows NT / 2000 / XP)
- I have tried Everything, now i need help (Viruses, Spyware and other Nasties)
- Finder can't be found! (OS X)
- Persistent spyware problems, HJT log included. (Viruses, Spyware and other Nasties)
- OS X: how does shareware expire? -and- what about the orphaned cruft in Library? (OS X)
- Help with HiJackTHis log please (Viruses, Spyware and other Nasties)
- Virus, Adware, or just explorer causing malfunctions-res://mshp.dll/http_404.htm (Viruses, Spyware and other Nasties)
Other Threads in the PHP Forum
- Previous Thread: Problem with $this
- Next Thread: Need help In installing PHP fourm and IIS
Views: 290 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email encode error file files folder form forms function functions google howtowriteathesis href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail menu methods mlm mod_rewrite multiple multipletables mysql oop parse paypal pdf php problem provider query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table template tutorial update updates upload url validation validator variable video web xml youtube





