A whole table full of checkboxes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
john_st
Forum Newbie
Posts: 4
Joined: Fri Jun 18, 2010 6:00 am

A whole table full of checkboxes

Post by john_st »

Hi there. This is my first post, so please be gentle :)

I have a table with about 15 columns and a variable amount of rows. In each row, the first column is the name, and the rest are movies in which the actor starred. In the beginning there are just empty checkboxes.

Image

I would like to check the actors which starred in the first movie, then click on the button in that column and "remember" that somehow in my database. If the actor starred in a movie then that checkbox is replaced with a green check mark image, if not a red cross image is put in.

I worked out the part of checking in the database if there should be a green or red image, but I can't figure out the part of storing the checked checkboxes in the database. Can anybody help me?
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: A whole table full of checkboxes

Post by andyhoneycutt »

Could you show us the table schema for all this?
john_st
Forum Newbie
Posts: 4
Joined: Fri Jun 18, 2010 6:00 am

Re: A whole table full of checkboxes

Post by john_st »

Yes of course. These are my tables using mysql.

Actors:

Code: Select all

CREATE TABLE  actors
( actorID TINYINT NOT NULL AUTO_INCREMENT PRIMARY KEY 
, firstname VARCHAR( 30 ) NOT NULL 
, lastname VARCHAR( 30 ) NOT NULL
) ENGINE = INNODB;
Movies:

Code: Select all

CREATE TABLE  movies 
( movieID TINYINT NOT NULL AUTO_INCREMENT PRIMARY KEY 
, movie VARCHAR( 3 ) NOT NULL
, starred VARCHAR( 3 ) NOT NULL
) ENGINE = INNODB;
ActorsMovies:

Code: Select all

CREATE TABLE actor_movies 
( actorID TINYINT NOT NULL
, movieID TINYINT NOT NULL 
, PRIMARY KEY ( actorID, movieID )
, INDEX actor_movies ( movieID, actorID )
, FOREIGN KEY ( actorID ) REFERENCES actors ( actorID )
, FOREIGN KEY ( movieID ) REFERENCES movies ( movieID )
) ENGINE = INNODB;
john_st
Forum Newbie
Posts: 4
Joined: Fri Jun 18, 2010 6:00 am

Re: A whole table full of checkboxes

Post by john_st »

anybody? :(
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: A whole table full of checkboxes

Post by McInfo »

Is it important to you to have an OK button for each column?
john_st
Forum Newbie
Posts: 4
Joined: Fri Jun 18, 2010 6:00 am

Re: A whole table full of checkboxes

Post by john_st »

Well it' my original idea, but if it could be done easier without it I'm up for it.

I thougt that I would check the checkboxes for movie 1 and then click the button in that column. Then that "checkedness" and "uncheckedness" would go into the database, and when the page reloads, the button for that column would be gone, and the previously checked checboxes would be replaced by an image of a green check mark, and the unchecked ones with an image of a red cross.
Post Reply