How do I allow my users to customize their dashboards in PHP - php

I'm confused on a basic concept. I'm working on a LAMP project where vendors submit products to companies for review. Each company has their own dedicated form that the vendors can access from their dashboard to submit products for review to the companies. Then the companies have their dashboard where they can review these products.
My question is how do I program for the companies to have the ability to switch the questions they want to ask of the vendors? So upon setting up their account I create a form for the companies that include ten questions of their choosing. Obviously there is a way with PHP for the companies to access these ten questions from their dashboard and to swap these questions out for others that will then populate on their forms that show up on the vendors dashboard. Since it affects my database code and my form code I'm confused on how to handle this and I haven't been able to come up with the right search terms for here or google that will show me resources on how to do this. What is the basic concept here? Am I writing code to literally overwrite the php source code for the companies forms page? Or is the database somehow involved with a global list of questions that are chosen? I am sure this is a basic function of php but I have never dealt with it so a "Mr. Potato Head" explanation and a link to a resource from the community would be real helpful.
EDITED:
I may have been asking this question wrong above. This is far more a php question than a MySQL question. I don't understand the concept of customized forms. If a company chooses to swap out one of their questions and I give them a page where they can adjust their questions, what happens after they hit submit and have selected a new set of questions? Do I set the PHP up to completely overwrite the source code of their form page? That doesn't seem right so I am looking for examples of customized forms....

How about you have a table of Questions with lots of possible questions
Then you have a table of Company_Questions which is just a subset of those questions, chosen by the company. You may then add a question to Questions or just create/swap an entry in Company_Questions to the selected Question.
I think you should look at some Data(base) Design books first, because you may be missing some key concepts.

If you have something like this in your database schema:
users(id, name, other params);
questions(id, question);
You need to do a 1:N relationship to save for all customers the questions their want.
user_que(id_user,id_question, order);
Note: the param 'order' is just to specify the order the client want the question, and to clarify you can add more columns if you want to that table.
Well with that you can do the job. Now some SQL
Get the questions from a client
SELECT q.question FROM questions q, user_que uq WHERE uq.id_user = $client_id
Get the clients who have one question
SELECT c.name FROM users c, user_que uq WHERE uq.id_question = $id_question
Hope it helps you.

Related

Dynamic links in php

I'm almost embarrassed asking this question since I know it should be quite simple yet I can't find an answer to it.
I have a html page with php code in it, that displays let's say a list of companies in a table. I want to make the names of the companies in the table be hyperlinks, such that when a user clicks on a company name, he/she is taken to a page that shows that company's details.
The issue is I cannot have a static page for each company because this list of companies can change every day. So the 'company details' page should be generated dynamically based on what the user clicks.
I am not sure how to approach this. all the questions I see out there seem to talk about static links and pages for static data.
Any guidance is be appreciated!
Every company in the table should have an ID property.
Then when you create the link, do something like this:
Company Name
In your company_details.php you can get the ID of the company from $_GET['id'].
That way you only have one page company_details.php for all companies.

php mysql one to many relationship or something else?

I am trying to figure out what to do from here. I am using mysql for my database.
In my form from mysql I wish to have the possibility for people to upload from 1 to many images that can be queried along with the data submitted in the form. I am not asking for someone to write me the code, but to point me in the right direction of what type of solution I can use or what I can read on to learn to get this done.
User example here:
1. a registered user is filling out a form for example a car for sale ad.
2. user wishes to upload images relating to that car sale ad.
3.if the user fills out the car for sale form and clicks submit/next.How to display the form the user just clicked submit in the next page to appear,so the user can add images there/here?
I hope someone can point me in the right direction or can give me their input on what else I can read on to do this.
Thank you in advance
Personally when I start having to get into complex HABTM relationships and the what I want to use an ORM. I personally use CakePHP's. It has a very robust relational mapping system (HasMany, HasOne, BelongsTo, HasAndBelongsToMany) which is a bit of a pain to learn to do in SQL your self.
If you don't have access to a server with the right php modules 3.0 can be a pain to install, but 2.0 has a really nice RubyOnRails style ActiveRecord system too.

symfony2 forms and many-to-many relations

I thought I'd see if anyone could point me in the right direction here - I have a users table and a contents table, and I want to keep track of what user is authorized to edit what content.
Thinking in a relational database way, a many-to-many relation table is the solution, adding rows of user_id & content_id for each authorization.
Many users can be authorized to edit a content piece, and a user is also of course able to have access to more than one content piece.
Now, the biggest issue I see (being a Symfony2 novice) is the admin form where an admin must be able to set these permissions, preferrably with a list of contents and checkboxes next to them, and have the form processor take care of the adding/deleting rows to that relationsl table.
Is the collection form field the right way to go here?
Any help is much appreciated.
I think the Doctrine2 documentation on Many-to-Many relations already gives you an answer on that question how to map the data.
The form issue is already explained in another SO question.

How to add reviews and rating to each record (clinic) on webpage, that is store in the database?

I want to add reviews and rating to each (clinic) record of the database. If people search a clinic, the webpage shows multiple (clinics) records on the webpage, and then user can rate and write review to any clinic or multiple clinics. Then each clinic will show there won rating stars.
Like in this link
http://search.yahoo.com/search?p=Quiet+Italian+Restaurant%2C+SF&fr=mkg063&ei=UTF-8
User can give different rat and write different reviews to any record like 1, 2, and 3 mentions in above link. Please help me, I will appreciate.
I am using php, html, javascript and mysql.
Your question is pretty broad, but the concepts are roughly equivalent to a CMS system. Content goes in (your reviews) Content goes out (displaying reviews from DB) User login system, and some sort of mechanism to allow the user to find records.
A previous version of this book/article is what helped get me into application development on the PHP side. http://articles.sitepoint.com/article/php-amp-mysql-1-installation It's got all the basics, the rest is up to you.

Let users choice modules they want

I'm making a social gaming network, for learning but mostly because php is alot of fun!
Anyway I want this future..
I wanna let my users chose which "modules" they want activated, like a message board on their profile, polls, buddy list, contact box. Some modules will have to be purchased with points.
Im thinking on something like this:
id
username
passwd
points
msgboard_activated
poll_activated
buddylist_activated
contactbox_activated
Just check if msgboard_activated equals to 1, then include that module on members profile
Some modules (feel free to come with suggestions of modules):
Message board (lets users leave messages on a specific users page)
Buddy list
Poll
I pretty much got the idea from (awesome site!):
http://www.fpsbanana.com/modules
Anyway, Let me hear your thought and idea of this!
Thanks alot and have a good day!
ps.(im BR so expect spelling errors etc)
Oie, Agamemon!
I would encourage you to try a different structure. For instance, three tables, as opposed to a single table.
First, your users table which represents everybody on your site. Second, a modules table which represents all possible modules. This way you can add more in the future without having to add columns to the user table, etc. And lastly we bring them together into a relationship with the usersmodule table, which shows what modules belong to each particular user.
I hope this gives you some direction.
table:users
userid
username
...
table:modules
moduleid
modulename
...
table:usermodules
userid
moduleid
...

Categories