Generate a few classes of the drop box, check, radio box, support database result set generation

zhaozj2021-02-12  145

? * 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. =

> / n "; return $ itemstart;} function getItemfoot () {$ itmend =" / n "; return $ item;} // =================================================================================================================================================================================================== ========= Function setAction {$ this-> action = "$ action";} function getAction () {Return $ this-> action. "";} Function SetName ($ name) {$ THIS-> Name = 'Name = "'. $ Name. '"; If ($ this-> multiple == true) $ this-> name =' name = "'. $ Name.' []" ';} function getName () {RETURN $ this-> name. "" "" "" "" "" "";} // ========================= function setId ($ ID) {$ this-> id = 'id = "'. $ ID. '";} Function getId () {return $ this-> id. "";} // ========= ================ Function setDir ($ dir) {$ dir = @ strtolower ($ dir); Switch ($ dir) {Case "Left": $ this-> DIR = "DIR = /" RTL / ""; Break; Case "Right": $ this-> DIR = "DIR = /" ltr / "; break;}} function getdir ()}} function getdir () {Return $ this-> DIR." "} // ========================= function setacckey ($ key) {$ this-> accesskey = 'accesskey =". $ Key. '";} function getacckey () {return $ this-> accesskey." ";} // =========================

Function setDisabled ($ Disabled) {if ($ Disabled == True) $ this-> disabled = "disabled";} function getDisabled () {Return $ this-> disabled. "";} // ====== =================== Function setsize ($ this-> size = 'size = "'. $ size. '"';} function getSize () {Return $ this-> size. "";} // =========================} // ======== ============================================================================================================================================= == // ====================================== / * # Classname Z99radio # @ Create by night # @ 2003-07-28 # Generate a radio group method: - setName Setting Name - SetITEM Setting Data (2D array, selected ID) - ReturnString direct return string - Returnarray Returns a one-dimensional array - show returnstring alias * /// === =================================00: $ = new z99radio (); $ item = array ("- 1" => "Confidential", "1" => "Men", "2" => "Female"); $ r-> setname ("sex"); $ r-> setItem ($ Item, 1); Echo $ RS- > Returbtring (); $ r-> retuanarray (); * / // ==============================

Class z99radio {var $ name = null; var $ selected = array (); var $ selected = null; var $ radioArray = array (); var $ radiostring = null; var $ action = null; // ===== ======================== function z99radio () {} // ============================================= =========== Function setName ($ this-> name = $ name;} function getName () {Return $ this-> name;} Function SetAction ($ action) {$ THIS -> action = $ action;} function getAction () {Return $ this-> action;} Function SETITEM ($ item, $ SELECTED = NULL) {$ this-> item = $ itm; $ this-> selected = $ SELECTED } # Name As long as one # value and label is a two-dimensional array # format array ("value" => "label"); function radio () {$ name = $ this-> getName (); $ itm = $ this -> Item; $ SELECTED = $ this-> SELECTED; $ Action = $ this-> action; $ i = 0; while (list ($ value, $ label) = Each ($ it ") {$ isselected = null;

IF ($ VALUE == $ SELECTED $ ISSELECTED = "Checked"; $ IDNAME = $ Name. "_". $ i; $ radio [] = "

> "Female"); $ SELECTED = Array ("2", "- 1"); $ r-> setname ("sex"); $ r-> setItem ($ item, $ SELECTED); $ r-> checkbox (); echo $ r-> show (); * /// ============================== Class z99checkbox {var $ Name = null; var $ item = array (); var $ selected = array (); var $ checkRay = array (); var $ checkstring = null; var $ action = null; var $ dbitem = false; var $ dbitem = false; var $ dbitem = false; Var $ itemLABLE; / / ============================= function z99Checkbox () {} // ======= ====================== Function setName ($ name) {$ this-> name = $ name;} function getName () {Return $ this-> Name ($ action) {$ this-> action = $ action;} function getAction () {RETURN $ THIS-> Action;} Function SETITEM ($ item, $ SELECTED = NULL) {$ this-> item = $ Item; $ this-> SELECTED = $ SELECTED;} // ================================================================================================================================================================================================= {$ Value = $ this-> ItemValue; $ lable = $ this-> itemLable; for ($ i = 0; $ i <= @ count ($ iTEM) -1; $ i ) {$ key = $ itm [$ I] [$ value]; $ VAR = $ ITEM [$ I]; $ ttrow [$ key] = $ var;} Return $ TTROW;} // =========== ================== Function checkbox () {$ name = $ this-> getName ();

$ item = $ this-> item; if ($ this-> dbitem == true) {$ item = $ this-> convitem ($ this-> item);} $ SELECTED = $ THIS-> SELECTED; $ Action = $ this-> action; $ i = 0; while (list ($ value, $ label) = Each ($ it)) {$ IsCheck = null; if (is_ARRAY ($ SELECTED) {reset ($ selected); $ SELECTEDCOUNT = COUNT ($ SELECTED); For ($ j = 0; $ j

转载请注明原文地址:https://www.9cbs.com/read-6188.html

New Post(0)