Read the list of categories that can be selected from the database
php / **************************************************************** **************** 'Description: Read the selected category list "Enter: StrlistType display type, including list (option), check box (Checkbox), single The name of the strlistName option, meaning when only radio boxes and check boxes; strslected has been selected, is a comma-separated string; Strtable stores the optional item database table name; strTextField Display the field of the name; StrValueField can be empty as the field of the value of the optional item. 'Output: a section of HTML code' '***************************************************** ********************* / CLASS CLS_CODEINFO {var $ strconn; // Set the connection string Function CONN ($ conn) {global $ strconn; $ strconn = $ CONN;
function getUserTypeName ($ intId) {return $ this-> Id2Name ( "user_type", "utf_name", "utf_id", $ intId);} function getUserType ($ strListType, $ strListName, $ strSelected, $ strWhere) {return $ this -> Gethtmlcode ("User_Type", "UTF_NAME", "UTF_ID", $ STRLISTTTTYPE, $ StrlistName, $ STRSELECTED, $ Strwhere);}
// Get the HTML code to display the last function getHtmlCode ($ strTable, $ strTextField, $ strvalueField, $ strListType, $ strListName, $ strSelected, $ strWhere) {global $ strConn; $ strResult = ""; $ strSql = "select" IF ($ strValuefield! = ") $ Strsql. = $ Strsql.", "; $ Strsql. = $ StrTextField." From ". $ StrTable; if ($ strwhere! =") {$ Strsql. = " $ strwhere;} $ strsql. = "ORDER BY". $ strTextField. "ASC"; $ r = mysql_query ($ strsql); while ($ = mysql_fetch_Array ($ r)) {ix ($ strlisttype == "option") {$ Strresult. = "
Strinstr ($ strslected, $ line [$ strruefield)) {$ strresult. = "checked";}} else {IF ($ this-> Strinstr ($ strselected, $ line [$ strresult)) {$ Strresult. = "Checked";}} $ strresult. = "> $ Strresult. = $ Line [$ strtextfield];}}} Return $ strresult;} // Determine if a string is included in a comma or semicolon-separated character Function Strinstr ($ Strlong, $ STRSHORT) {IF (StrPos ($ strlong, ")> 0 || StrPos ($ strlong,"; ")> 0) {ix ($ strlong,", " )> 0) {$ strlong, ",");} else {$ arrstrlong = split ($ strlong, ";");} for ($ i = 0; $ i <= ubound ($ arrstrlong $ I ) {IF ($ arrstrlong [i]) == TRIM ($ strshort)) {$ boorell = true; break;} else {$ booresult = false;}}} else {IF ($ Strlong! = "" && $ strshort! = "") {IF ($ strlong == $ strshort) {$ boorell = true;} else} else {$ booresult = false;}} return = false;}} returnome }
// convert a ID number into the corresponding name Function ID2Name ($ STRTABLE, $ STRNAMEFIELD, $ Stridfield, $ intid) {global $ strconn; $ strsql = "select". $ Strnamefield. "From". $ StrTable. "Where "$ Stridfield." = "$ Intid." ORDER BY ". $ StridField." DESC LIMIT 0, 1 "; // Echo $ strsql; $ r = mysql_query ($ strsql) OR Die (" Invalid Query: " . Mysql_error ()); if ($ line = mysql_fetch_array ($ strresult = $ line [0];} else {$ strresult = false;}}}}}}}?>