? * All rights reserved * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met:. * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and / or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR aND CONTRIBUTORS `` AS IS '' aND * ANY EXPRESS oR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING , BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE Or OtherWise) arising in any way * out of the use of this software, even if adview of the possibility of * such Damage. * / # Several classes of the dropboard, check, radio box,
Support database results set / *************************************************************** *********************************************************** **************** The PHP File Create By NightKids * E-Mail: weidewang@magus-soft.com* Home: * author: NightKids ** * * last Review: 2003 -07-27 10:45:05 ** Disclaimer: Any individual or group can modify, propagate code, can be used for any place (any loss or dispute arising from it). * If you have any good suggestions and comments, please contact me. * Please use or disseminate this annotation, respect the person's labor results. Thank you !! ** Thank you: All friends around you, people who support me. * Netizens and friends with all selfless suppliers. All PHP supporters! * ** Development environment: freebsd5.1 apache / 2.0.47 php 5.0.1b Zend Engine v2.0.0 mysql 4.1.14 zend Optimizer V2.1.0 * * Requirements: **** *********************************************************** *********************************************************** ***** / // =========== HTML drop-column class / / According to an array generated a drop-down box // function: can initialize one of the selected one, the default is the first item / * Drop-down box: SELECT Options: option: SELECTED Name: NameID: IDCSS Style: Class Project Tag: Tag Value: * /// ------------------- -------------------------------------------------- ------------------- / * $ dbc = mysql_connect (); mysql_select_db ("felonious", $ dbc); // Connect to $ = mysql_Query ("SELECT * From felonious ", $ dbc); // Database Operation While ($ row = mysql_fetch_array ($)) {$ rows [] = $ row;}
$ Item = array ("null" => "No option", "1" => "fff", "2" => "aaaaaaa"); $ SELECTED = Array ("10", "15", "20 "); // When selective, the first element is valid $ ds = new cxselectdown (); $ ds-> dbitem = true; $ ds-> itemvalue =" auto_id "; // item value, data table Field name $ ds-> itemlable = "felonious"; // item tag, field name in the data table $ ds-> multiple = false; $ ds-> setname ("test"); $ ds-> setStyle (" "); $ Ds-> setid (" test "); $ ds-> setdir (" right "); $ ds-> setacckey (" b "); $ ds-> setdisabled (false); $ ds-> Setsize (0); $ ds-> setItem ($ ROWS, $ SELECTED); Echo $ DS-> Show (); // --------------------- -------------------------------------------------- ---------------- The simplest usage $ ds = new cxselectddown (); $ ds-> setItem ($ item); Echo $ ds-> show (); // -------------------------------------------------- ----------------------------------- Based on the ROW obtained from the database to generate a drop-down box method: setItem setting Project Data Parameters $ ROWS Item Array, $ SELECTED Currently selected item This value is a value or array (when multiple) attribute: dbitem [true / false] Default FalseItemValue project value, only dbitem is True Valid ItemLable item Label, only dbitem is True When the DBITEM is TRUE, the data of the method SETITEM must be the data taken with mysql_fetch_array. Otherwise, the array structure is $ itm = array ("null" => "No option", "1" => " fly FFF "," 2 "=>" aaaaaaa "," value "=>" lable "); * / class cxselectdalog {// ===================== ==== // Value Tag Var $ _NULLITEM = Array ("null" => "No option"); var $ _item = array (); var $ _selected = null; // ======== =======
========== Var $ name = null; var $ ID = null; var $ pipe = null; var $ accesskey = null; var $ disabled = null; var $ size = null; var $ action = Null; // Other operation onchange .... / / ========================= var $ dbitem = false; // If it is from the database The number of the acquired array also sets the following parameter var $ itemValue; // item value VAR $ itemLABLE; // item tag VAR $ multiple = false; // Multi-selection, list box / / ======= ================== function cxselectdown () {} // ======================== = Function setItem ($ item = null) {if (! EMPTY ($ item)) $ this -> _ item = $ item; else $ this -> _ item = $ this -> _ nullitem; $ this-> _Selected = $ SELECTED;
IF ($ this-> dbitem == true) // is directly from database $ item [] = $ 10 $ this -> _ item = $ this-> convitem ($ item); // Conversion array
} // =================================, $ value = $ this-> itemvalue; $ lable = $ this- > ItemLable; For ($ I = 0; $ I <= @ count ($ it) -1; $ i ) {$ key = $ itm [$ I] [$ value]; $ var = $ itm [$ I] [$ lable]; $ TTROW [$ key] = $ var;} Return $ TTROW;} // ========================= Function Show () {$ ItemStart = $ this-> GetItemHead (); $ itembody = $ this-> GetItemBody (); $ item = $ this-> getItemfoot (); $ item = $ itMstart. $ Itembody. $ Item; return. Item;} Function GetItemBody () {$ item = $ this -> _ item; $ selected = $ this -> _ selected; $ SELECTEDNUM = @ count ($ selected); while (@List ($ value, $ lable) = @ Each ($ ISSELECTED = NULL; if ($ this-> multiple == true) {// Multi-selection processing for ($ I = 0; $ I <= $ SELECTEDNUM-1; $ i ) {IF ( $ value == $ SELECTED [$ I]) {$ ISSELECTED = "SELECTED";}}} else}}} else {// radio processing IF ($ value == $ selected) $ isselected = "selected";} $ itMstr. =