bin bei meinem Versuch, ein Dropdownfeld nach einem Wert aus der DB vorausfüllen zu lassen, kläglioch gescheitert.
Habs folgendermaßen versucht:
1. Eine neue Funktion ähnlich der tz_select, die die Zeitzone auswählt in der includes/functions_selects.php eingefügt:
Code: Alles auswählen
//
// Pick a cat, any cat ...
//
function cat_select($default, $select_name = "book_cat")
{
global $phpEx, $phpbb_root_path, $db;
$default = '1';
$sql = "SELECT *
FROM " . BOOK_CATEGORIES_TABLE . "";
$result = $db->sql_query($sql);
$cats = array();
while ( $row = $db->sql_fetchrow($result) )
{
$cats['name'] = $row['cat_name'];
$cats['id'] = $row['cat_id'];
}
@asort($cats);
@reset($cats);
$cat_select = '<select name="' . $select_name . '">';
while ( list($cats['id'], $cats['name']) = @each($row) )
{
$selected = ( $default == '1' ) ? ' selected="selected"' : '';
$cat_select .= '<option value="' . $cats['id'] . '"' . $selected . '>' . $cats['name'] . '</option>';
}
$cat_select .= '</select>';
return $cat_select;
}
Code: Alles auswählen
'CAT_SELECT' => cat_select('1', 'book_cat'),
Code: Alles auswählen
</tr>
<td class="row1">{L_CATEGORY}</td>
<td class="row2">
{CAT_SELECT}
</td>
</tr>
mfg Johny