ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:recordset:getmenu2

This is an old revision of the document!


getMenu2

Syntax
string getMenu2(
    optional string $selectName='',
    optional mixed $defaultValue=false,
    optional bool $blankFirstItem=true,
    optional bool $multiple=fale,
    optional int $numberOfRows=0,
    optional string $optionalAttributes='',
    )

Description

The function getMenu2() Generates an HTML SELECT tag string from a recordset, and return the string. If the recordset has 2 cols, the 1st column is compared with the FIRST column.

Parameters

$selectName

name of SELECT tag

$defaultValue

The value to highlight. Use an array for multiple highlight for listbox.

$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

$optionalAttributes

Additional attributes to defined for SELECT tag, useful for holding javascript onChange='…' handlers.

$compareAgainstFirstCol

When we have 2 cols in recordset, we compare the defstr with column 0 (1st col) if this is true.

Usage

/*
* Connect to DB2 Sample Database
*/
$SQL = "SELECT actdesc,actno FROM act ORDER BY actno
$result = $db->execute($SQL);
 
$html = $result->getMenu2('mySelect','30');
 
print $html
*/
<select name="mySelect" >
<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>
v5/reference/recordset/getmenu2.1439594249.txt.gz · Last modified: 2017/04/21 11:37 (external edit)