If I understand you correctly.. you want to loop through a select statement
and put the enum values in the value of the select box?
If that's the case then here is how you would do that...
<select>
<?php
$query = "select * from foo where bar";
$result = mysql_query($query);
While($row = mysql_fetch_row($result)) {
$enumVal = $row[0];
$name = $row[1];
Print "<option value=\"$enumVal\">$name</option>";
}
?>
</select>
Hope that speaks to your question.
Jason
-----Original Message-----
From: mel list_php [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 14, 2005 5:54 AM
To: [email protected]
Subject: [PHP-DB] retrieve enum values
Hi!
I have a column type enum in mysql.
At the moment the possible values are 1,2 and 3.
I make a form for my user to modify that value, something like:
<select>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
</select>
I may need to add a value 4 to the enum, and in that case I would like to
avoid modifying the code.
I would like to know it it is possible to have something like:
select possible_enum_values from table ...
and then having a loop through these values.
I can't select distinct values in that column because one value may not
exist yet and I don't want to have fake records.
I found that in the mysql doc and was wondering if there is an already
implemented php function intsead of having to parse:
" If you want to determine all possible values for an ENUM column, use SHOW
COLUMNS FROM tbl_name LIKE enum_col and parse the ENUM definition in the
second column of the output."
Any idea?
Melanie
_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today!
http://www.msn.co.uk/messenger
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php