ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:recordset:getmenu3

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
v5:reference:recordset:getmenu3 [2016/01/17 02:50] – ↷ Page moved from v5:reference:getmenu3 to v5:reference:recordset:getmenu3 mnewnhamv5:reference:recordset:getmenu3 [2019/01/01 22:09] mnewnham
Line 1: Line 1:
 ====== getMenu3 ====== ====== getMenu3 ======
 ~~NOTOC~~ ~~NOTOC~~
 +<WRAP info>
 +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.
 +</WRAP>
 <WRAP right box> <WRAP right box>
 == Syntax == == Syntax ==
Line 7: Line 10:
       optional mixed $defaultValue=false,       optional mixed $defaultValue=false,
       optional bool $blankFirstItem=true,       optional bool $blankFirstItem=true,
-      optional bool $multiple=fale,+      optional bool $multiple=false,
       optional int $numberOfRows=0,       optional int $numberOfRows=0,
       optional string $optionalAttributes='',       optional string $optionalAttributes='',
 +      optional bool $compareSelectedCol0=true
       )       )
      
Line 15: Line 19:
 </WRAP> </WRAP>
 ===== Description ===== ===== Description =====
-The function ''getMenu3()'' Generates an HTML MULTI-SELECT tag string from a recordset, and return the string. The recordset requires 3 columns, the 3rd being used for the optgroup. +The function ''getMenu3()'' Generates an HTML OPTGROUP select string from a recordset, and returns the string. The recordset requires 3 columns, the 3rd being used for the optgroup. The select can be defined as either a single or multiple select 
  
-If a multiple option is not given, the function behaves exactly like ''getMenu2()''. 
  
 ===== Parameters ===== ===== Parameters =====
Line 29: Line 32:
 Set true to create a multi-select box Set true to create a multi-select box
 ==== $numberOfRows ==== ==== $numberOfRows ====
-Number of rows to show for multi-select box+Number of rows to show for multi-select box. If not a multi-select, this field has no meaning.
 ==== $optionalAttributes ==== ==== $optionalAttributes ====
-Additional attributes to defined for SELECT tag, useful for holding javascript onChange='...' handlers. +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 ==== +==== $compareSelectedCol0==== 
-When we have 2 cols in recordset, we compare the defstr with column (1st colif this is true+When we determine the selected tagby default we compare the value provided against the first column in the recordset (the option value). By changing this to false, we compare the value against the second.
 ===== Usage ===== ===== Usage =====
 <code php> <code php>
Line 39: Line 42:
 * Connect to DB2 Sample Database * Connect to DB2 Sample Database
 */ */
 +$db->setFetchMode(ADODB_FETCH_NUM);
 $SQL = "SELECT actdesc,actno,actgroup FROM act ORDER BY actgroup, actno $SQL = "SELECT actdesc,actno,actgroup FROM act ORDER BY actgroup, actno
 $result = $db->execute($SQL); $result = $db->execute($SQL);
  
-$html = $result->getMenu3('mySelect','30',true,true,10);+$html = $result->getMenu3('mySelect','30',true,true,10,'id="mySelect" class="myclass-1 myclass-2");
  
 print $html print $html
Line 49: Line 53:
  
 <code html> <code html>
-<select name="mySelect[]" multiple size="10" >+<select name="mySelect[]" multiple size="10" id="mySelect" class="myclass-1 myclass-2">
 <option></option> <option></option>
 <optgroup label='ANALYSIS/DESIGN'> <optgroup label='ANALYSIS/DESIGN'>
v5/reference/recordset/getmenu3.txt · Last modified: 2019/01/01 23:50 by mnewnham