* @package HTML_QuickForm_advmultiselect * @subpackage Examples * @access public * @example examples/qfams_basic_2.php * qfams_basic_2 source code * @link http://www.laurent-laville.org/img/qfams/screenshot/basic2.png * screenshot (Image PNG, 605x283 pixels) 5.17 Kb */ require_once 'DB.php'; require_once 'HTML/QuickForm.php'; require_once 'HTML/QuickForm/advmultiselect.php'; require_once 'dsn_qfams_basic2.inc'; // dsn data: $user, $pass, @$host, $db PEAR::setErrorHandling(PEAR_ERROR_DIE); $dsn = "mysql://$user:$pass@$host/$db"; $db = DB::connect($dsn); // query to get all users of group #1 (available users list) $queryAll = 'SELECT userid, CONCAT(lastname, " ", firstname) AS useridentity ' . 'FROM user WHERE gid = 1'; // query to get all users affected of group #1 (selected users list) $querySel = 'SELECT userid FROM user WHERE gid = 1 AND affect = 1'; // execute query to get ident of users affected $affected_user =& $db->getCol($querySel); $form = new HTML_QuickForm('amsBasic2'); $form->removeAttribute('name'); // XHTML compliance // same as default element template but wihtout the label (in first td cell) $withoutLabel = <<<_HTML
'; print_r($clean); echo ''; } else { $form->display(); } ?>
CREATE TABLE user ( userid VARCHAR(5) NOT NULL, gid INT NOT NULL, affect INT NOT NULL, lastname VARCHAR(50)NOT NULL, firstname VARCHAR(50) NOT NULL, PRIMARY KEY (userid) ); INSERT INTO user VALUES ('MJ001', 1, 0, 'Martin', 'Jansen'); INSERT INTO user VALUES ('BG001', 1, 1, 'Greg', 'Beaver'); INSERT INTO user VALUES ('CD001', 1, 0, 'Daniel', 'Convissor'); INSERT INTO user VALUES ('LL001', 2, 1, 'Laurent', 'Laville');