ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:recordset:getmenu

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
v5:reference:recordset:getmenu [2019/01/01 22:42] mnewnhamv5:reference:recordset:getmenu [2019/11/24 00:16] (current) – Add wrap around fetch mode note dregad
Line 1: Line 1:
 ====== getMenu ====== ====== getMenu ======
-<WRAP info> 
-You must set ADODB_FETCH_MODE to ADODB_FETCH_NUM before calling this method. 
-</WRAP> 
 ~~NOTOC~~ ~~NOTOC~~
 <WRAP right box> <WRAP right box>
 == See Also == == See Also ==
-[[v5:reference:recordset:getmenu|getMenu2()]]\\ +[[v5:reference:recordset:getmenu2|getMenu2()]]\\ 
-[[v5:reference:recordset:getmenu2|getMenu3()]]\\+[[v5:reference:recordset:getmenu3|getMenu3()]]\\
 == Syntax == == Syntax ==
   string getMenu(   string getMenu(
-      optional string $selectName='',+      string $selectName,
       optional mixed $defaultValue=false,       optional mixed $defaultValue=false,
-      optional bool $blankFirstItem=true, +      optional mixed $blankFirstItem=true, 
-      optional bool $multiple=fale,+      optional bool $multiple=false,
       optional int $numberOfRows=0,       optional int $numberOfRows=0,
       optional string $optionalAttributes='',       optional string $optionalAttributes='',
Line 22: Line 19:
 </WRAP> </WRAP>
 ===== Description ===== ===== Description =====
-The function ''getMenu()'' Generate an HTML SELECT tag string from a recordset, and return the string. If the recordset has 2 cols, the 1st column is is are compared with the FIRST column.+ 
 +The function ''getMenu()'' generates an HTML SELECT tag string from a recordset, and returns the string. 
 + 
 +If the recordset has a single column, the option values and descriptions are the same. 
 +If it has 2 columns, the first one is the description and the second is the value. By default, the 2nd column is matched against ''$defaultValue'', if provided 
 + 
 +Any extra column beyond the first two will be discarded. 
 + 
 +<WRAP info left> 
 +Until ADOdb 5.20.13, this method required that [[v5:reference:adodb_fetch_mode|ADODB_FETCH_MODE]] be set to ''ADODB_FETCH_NUM'' prior to execution of the SQL statement that will provide the recordset. Starting with 5.20.14, all fetch modes are supported 
 +</WRAP> 
 ===== Parameters ===== ===== Parameters =====
 ==== $selectName ===== ==== $selectName =====
 name of SELECT tag name of SELECT tag
 ==== $defaultValue ==== ==== $defaultValue ====
-The value to highlight. Use an array for multiple highlight for listbox.+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 ==== ==== $blankFirstLine ====
-true to leave the 1st item in list empty+This parameter has the following available options: 
 + 
 +  * true (default) - creates an empty ''<option></option>'' tag 
 +  * false - does not creates an empty ''<option></option>'' tag 
 +  * string value - creates an ''<option value="">STRING</option>'' tag 
 +  * string value format ''value:description'' - creates an ''<option value='value'>description</option>'' tag 
 ==== $multiple ==== ==== $multiple ====
 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. a multi-select box is not created, 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 ==== ==== $compareAgainstFirstCol ====
-When we have 2 cols in recordsetwe compare the defstr with column (1st col) if this is true. +If we have 2 columnsby 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). This works even if the list of selected items is an array
 ===== Usage ===== ===== Usage =====
 <code php> <code php>
Line 46: Line 60:
 $result = $db->execute($SQL); $result = $db->execute($SQL);
  
-$html = $result->getMenu('mySelect','DEFINE SPECS');+$html = $result->getMenu('mySelect', 
 +                         'DEFINE SPECS', 
 +                         true, 
 +                         false, 
 +                         false, 
 +                         'id="mySelect" class="myclass-1 myclass-2"');
  
 print $html print $html
-*/+
 </code> </code>
  
 <code html> <code html>
-<select name="mySelect" >+<select name="mySelect" id="mySelect" class="myclass-1 myclass-2">
 <option></option> <option></option>
 <option value='10'>MANAGE/ADVISE</option> <option value='10'>MANAGE/ADVISE</option>
v5/reference/recordset/getmenu.1546378933.txt.gz · Last modified: 2019/01/01 22:42 by mnewnham