enum-selectbox
Code (php)
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
<?php
function enum($object) {
list($table, $col) = explode(".", $object);
$row=@mysql_fetch_assoc(mysql_query("SHOW COLUMNS FROM ".$table." LIKE '".$col."'"));
return ($row ? explode("','",preg_replace("/(enum|set)\('(.+?)'\)/","\\2",$row['Type'])) : array(0=>'None'));
}
?>
function enum($object) {
list($table, $col) = explode(".", $object);
$row=@mysql_fetch_assoc(mysql_query("SHOW COLUMNS FROM ".$table." LIKE '".$col."'"));
return ($row ? explode("','",preg_replace("/(enum|set)\('(.+?)'\)/","\\2",$row['Type'])) : array(0=>'None'));
}
?>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
function create_selectbox($cat,$table, $search, $skip=false){
$skip = explode(',',$skip);
$row = @mysql_fetch_assoc($query = mysql_query("SELECT $cat FROM $table WHERE $search='".@$_GET['id']."'"));
echo "<SELECT name=\"".$cat."\" style=\"margin:1px 0;width:300px;\">\n";
echo "\t<option value=\"\">Maak uw keuze</option>\n";
foreach(enum("PSH.".$cat) as $item){
if (!in_array($item,$skip))
echo "\t<option value=\"".$item."\" ". (($row[$cat] == $item) ? "selected=\"selected\"" : "") .">".get_txt($item)."</option>\n";
}
echo "</SELECT>";
}
?>
function create_selectbox($cat,$table, $search, $skip=false){
$skip = explode(',',$skip);
$row = @mysql_fetch_assoc($query = mysql_query("SELECT $cat FROM $table WHERE $search='".@$_GET['id']."'"));
echo "<SELECT name=\"".$cat."\" style=\"margin:1px 0;width:300px;\">\n";
echo "\t<option value=\"\">Maak uw keuze</option>\n";
foreach(enum("PSH.".$cat) as $item){
if (!in_array($item,$skip))
echo "\t<option value=\"".$item."\" ". (($row[$cat] == $item) ? "selected=\"selected\"" : "") .">".get_txt($item)."</option>\n";
}
echo "</SELECT>";
}
?>