This topic is locked

List view and splitted checkboxes

2/24/2011 6:33:34 AM
PHPRunner General questions
P
pvdemael author

I am developping an applications for project management.
The table project basically has as fields project_id and project_name.

Each project also uses resources which which are stored in the resources table with fields resource_id and resource_name.

The link between the two tables is in the table project_has_resources table which stores project_id and resource_id.

This is just a basic many-to-many relationship (project has many resources, resource can be used by many projects).

When adding a new project, the resources can be chosen with lookupwizard checkboxes. They are stored seperately in the project_has_resources table as found in http://xlinesoft.com/phprunner/docs/select_multiple_values.htm.
The SQL looks like this
SELECT

project.project_id,

project.name,

project_has_resources.resource_id

FROM project

LEFT OUTER JOIN project_has_resources ON project.project_id = project_has_resources.project_id
The problem now is in the list view. If I add a new project with resources, the list view shows the newly added project as many times as the count of the checked resources(which is logical).
I need a solution to this problem. I thought about to possible solutions:

  1. Build the project and edit the project_settings.php or project_add.php manually before upload.
  2. Use a view without resources for the list display and point the add and edit links in the list view to the view with the resources
  3. Don't split the checkbox (not preferable with respect to database normalisation)
    I think (hope) that some of you have a more elegant solution.
    Thanks in advance
    Pieter

Sergey Kornilov admin 2/24/2011

I would recommend to take a look at many-to-many relationship implementation described in this article:

http://www.asprunner.com/forums/topic/16295-implementation-of-many-to-many-relationships/
You can also check 'How to setup Many-to-Many relationships' tutorial at http://xlinesoft.com/phprunner/php-database.htm

P
pvdemael author 2/24/2011

Thanks for the link (it was me
However, this is not exactly what I want. The thing is that I want the user to be able to use only checkboxes. Because of the fact that I split the checkboxes in individual entries in the project_has_resources table, the join query returns several rows.

Another solution came to my mind: could I filter the rows using events so that only unique project_id values are shown. But I don't now how to do it.
I will post the application on my demo account tomorrow to show what I mean

Thx
Pieter