简体   繁体   English

如何允许我的用户在PHP中自定义他们的仪表板

[英]How do I allow my users to customize their dashboards in PHP

I'm confused on a basic concept. 我对一个基本概念感到困惑。 I'm working on a LAMP project where vendors submit products to companies for review. 我正在一个LAMP项目中,供应商将产品提交给公司进行审查。 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. 显然,PHP提供了一种方法,使公司可以从其仪表板访问这十个问题,并将这些问题交换给其他人,然后将其填充在供应商仪表板上显示的表格中。 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. 由于它会影响我的数据库代码和表单代码,因此我对如何处理它感到困惑,而且我无法为此处或Google提出正确的搜索字词,这些字词无法向我显示如何执行此操作的资源。 What is the basic concept here? 这里的基本概念是什么? Am I writing code to literally overwrite the php source code for the companies forms page? 我是否在编写代码以覆盖公司表单页面的php源代码? 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. 我确信这是php的基本功能,但是我从未处理过它,因此对“ Potato Head”先生的解释和从社区来的资源链接将非常有帮助。

EDITED: I may have been asking this question wrong above. 编辑:上面我可能一直在问这个问题。 This is far more a php question than a MySQL question. 这远不是一个MySQL问题,而是一个PHP问题。 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? 我是否将PHP设置为完全覆盖其表单页面的源代码? 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. 您如何拥有一个包含许多可能问题的问题表,然后又有了一个Company_Questions表,该表只是公司选择的那些问题的一部分。 You may then add a question to Questions or just create/swap an entry in Company_Questions to the selected Question. 然后,您可以将问题添加到问题中,或仅在Company_Questions中创建/交换所选条目的条目。

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); 用户(id,名称,其他参数); questions(id, question); 问题(id,问题);

You need to do a 1:N relationship to save for all customers the questions their want. 您需要建立1:N关系,以为所有客户保存他们想要的问题。

user_que(id_user,id_question, order); 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 现在一些SQL

Get the questions from a client SELECT q.question FROM questions q, user_que uq WHERE uq.id_user = $client_id 从客户端获取问题 SELECT q.question来自问题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 获取有一个问题的客户端从用户c,user_que uq WHERE uq.id_question = $ id_question中选择c.name

Hope it helps you. 希望对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM