help needed with form and mysql design.

From: Date: Sun, 02 Feb 2003 14:57:29 +0000
Subject: help needed with form and mysql design.
Groups: php.general 
Request: Send a blank email to php-general+get-133996@lists.php.net to get a copy of this message
Hi, I'm having trouble designing a good html-form/MySQL combination for an access rights system. I'm having three tables in MySQL: members (with member information for my site), albums (with information for separate albums with digital photos on my site) and accessrights (which should function as a "bridge" between members and albums, controling which albums a specific member could view). accessrights is defined by the following: CREATE TABLE accessrights ( albumid INT, userid INT, access ENUM("Y","N") DEFAULT "N" NOT NULL, UNIQUE (albumid, userid) ); albumid is from the albums table, and userid from the members table. For each member/album combination I want accessrights to contain one entry with access set to either Y or N. So far everythings alright. But how do I build a system that lets me control the entries in accessright? Right now, I'm trying with a form for album editing which contains something like this: db_connect($dbuser, $dbpassword, $dbdatabase); $query = "SELECT userid FROM members"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { echo($row[0]); ?> <INPUT TYPE="checkbox" name="<?php echo($row[0])?>" VALUE="YES"> } This creates a checkbox for every member on my site. But the problem is that only checked boxes are passed on to the next script, which process the form for album-editing. This means that if I uncheck a box that's been checked before, this information isn't passed along. From what I understand, information about unchecked boxes is never passed? Right now, my solution is to first set the field access in the table accessrights to N for every user and then update the table with an Y for those with checked boxes. But how can I limit the MySQL queries to just include members for which the access field has been changed? -- anders thoresson

« previous php.general (#133996) next »