This is an old revision of the document!
getMenu
This method requires that ADODB_FETCH_MODE be set to ADODB_FETCH_NUM prior to execution of the SQL statement that will provide the recordset.
See Also
Syntax
string getMenu( optional string $selectName='', optional mixed $defaultValue=false, optional bool $blankFirstItem=true, optional bool $multiple=false, optional int $numberOfRows=0, optional string $optionalAttributes='', optional bool $compareAgainstFirstCol=true )
Description
The function getMenu()
Generate an HTML SELECT tag string from a recordset, and return the string.
If the returned recordset has a single column, the option values and descriptions are the same.
If the returned recordset has 2 cols, the 1st column is the description and the 2nd column is the value. By default, the 2nd column is matched against the defaut, if provided.
Parameters
$selectName
name of SELECT tag
$defaultValue
The value to highlight. Use either a string for a single value to match, or a numeric array if a multiselect box is going to be built and there are multiple matching defaults.
$blankFirstLine
true to leave the 1st item in list empty
$multiple
Set true to create a multi-select box
$numberOfRows
Number of rows to show for multi-select box. If. a multi-select box is not created, this field has no meaning.
$optionalAttributes
Additional attributes to defined for SELECT tag, useful for holding javascript onChange='…' handlers or class information. Note that by default, the select box is generated without an id, so this should be included here.
$compareAgainstFirstCol
If we have 2 columns, by default the default value is located by matching against the 2nd column (the value). By setting this flag to false, we can locate the selected option by matching against the 1st column (the description).
Usage
/* * Connect to DB2 Sample Database */ $SQL = "SELECT actdesc,actno FROM act ORDER BY actno $result = $db->execute($SQL); $html = $result->getMenu('mySelect', 'DEFINE SPECS', true, false, false, 'id="mySelect" class="myclass-1 myclass-2"'); print $html
<select name="mySelect" id="mySelect" class="myclass-1 myclass-2"> <option></option> <option value='10'>MANAGE/ADVISE</option> <option value='20'>ESTIMATE COST</option> <option value='30' selected>DEFINE SPECS</option> <option value='40'>LEAD PROGRAM/DESIGN</option> <option value='50'>WRITE SPECS</option> <option value='60'>DESCRIBE LOGIC</option> <option value='70'>CODE PROGRAMS</option> <option value='80'>TEST PROGRAMS</option> <option value='90'>ADM QUERY SYSTEM</option> <option value='100'>TEACH CLASSES</option> <option value='110'>DEVELOP COURSES</option> <option value='120'>PERS AND STAFFING</option> <option value='130'>OPER COMPUTER SYS</option> <option value='140'>MAINT SOFTWARE SYS</option> <option value='150'>ADM OPERATING SYS</option> <option value='160'>ADM DATA BASES</option> <option value='170'>ADM DATA COMM</option> <option value='180'>DOCUMENT</option> </select>