Forum Moderators: coopster
Array
(
[0] =>
[1] => mid
[2] => best
[3] => average
)
But here in my select options ass you can see I have to add this: $abbrev++; to make it work.
I guess enum does not start with 0 it starts with 1.
Is this OK the way I am doing this?
$i = 1;
foreach ($TypeA as $abbrev => $full)
{
$abbrev++;
if ($full == TypeB) {
echo "<option value='$abbrev' selected>$full</option>";
} else {
echo "<option value='$abbrev'>$full</option>";
}
$i++;
}
function getEnumOptions($table, $field) {
$finalResult = array();
if (strlen(trim($table)) < 1) return false;
$query = "show columns from $table";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)){
if ($field!= $row["Field"]) continue;
//check if enum type
if (ereg('enum.(.*).', $row['Type'], $match)) {
$opts = explode(',', $match[1]);
foreach ($opts as $item)
$finalResult[] = substr($item, 1, strlen($item)-2);
}
else
return false;
}
return $finalResult;
}
function getEnumOptions($table, $field)
{
$finalResult = array();
$count = 1;
if (strlen(trim($table)) < 1) return false;
$query = "show columns from $table";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
if ($field!= $row["Field"]) continue;
//check if enum type
if (ereg('enum.(.*).', $row['Type'], $match)) {
$opts = explode(',', $match[1]);
foreach ($opts as $item) {
$finalResult[$count++] = substr($item, 1, strlen($item)-2);
}
} else {
return false;
}
return $finalResult;
}
}