5
I'm doing this (Below) and I have the "status" column of the db set to 1's where I want the item selected but it doesn't seem to select any of the formselect items:
$select_defaults = new XoopsFormSelect("","defaults","","29",true);
$tray_defaults = new XoopsFormElementTray(_MM_LAYERS, " ");
$tray_defaults->addElement($select_defaults);
$sql = 'SELECT id,status,name FROM '.$xoopsDB->prefix('gis_layers').' ORDER BY id';
$result = $xoopsDB->query($sql);
while(list($id,$status,$name) = $xoopsDB->fetchRow($result)) {
$select_defaults->addOption($name,$name);
$select_defaults->setValue($status);
echo "$status-";
}
DB table looks like:
mysql> describe xoops_gis_layers;
+--------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+------------------+------+-----+---------+----------------+
| id | int(15) unsigned | | PRI | NULL | auto_increment |
| status | varchar(255) | | | 1 | |
| name | varchar(255) | | | | |
+--------+------------------+------+-----+---------+----------------+
+----+--------+------------------------------+
| id | status | name |
+----+--------+------------------------------+
| 1 | 0 | Locale |
| 2 | 0 | Buildings |
| 3 | 0 | Businesses |
| 4 | 0 | Institutions |
| 5 | 0 | Physicians |
| 6 | 0 | Hospitals |
| 7 | 0 | Recreation Area |
| 8 | 0 | Petroleum Facilities |
| 9 | 0 | Petroleum Interconnects |
| 10 | 0 | Transmission Lines |
| 11 | 0 | Hydroelectric Plant |
| 12 | 0 | Power Plants |
| 13 | 0 | Electric Substations |
| 14 | 0 | NRC Facilities |
| 15 | 1 | Highways |
| 16 | 0 | Streets (Local) |
| 17 | 0 | Streets |
| 18 | 1 | Railroads |
| 19 | 1 | Rivers and Streams |
| 20 | 0 | Pipelines |
| 21 | 0 | DOE Site Buildings |
| 22 | 0 | DOE Areas |
| 23 | 0 | NRC Emergency Planning Zones |
| 24 | 0 | Zip Code (area) |
| 25 | 0 | Counties |
| 26 | 0 | DOE. Sites |
| 27 | 0 | Parks |
| 28 | 0 | Landmarks |
| 29 | 0 | Airports |
| 30 | 0 | Major Water |
| 31 | 1 | Lakes and Reservoirs |
| 32 | 0 | Urban Places |
| 33 | 0 | Federal Land (areas) |
| 34 | 1 | States |
| 35 | 1 | Countries |
| 36 | 1 | Oceans |
+----+--------+------------------------------+
Thanks
Doug P