470,855 Members | 1,219 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,855 developers. It's quick & easy.

Populating form item from SQL enum set Rev#2

$sql = "SHOW COLUMNS FROM table LIKE 'subject' ";
$qry = mysql_query($sql) or die("Query not valid: " . mysql_error());
$res = mysql_fetch_object($qry);
// This returns a row with a field 'Type' containing 'enum(...)'

$res->Type = str_replace('enum(\'', '', $res->Type);
$res->Type = str_replace('\')', '', $res->Type);
//now the string is something like this: one','two','three

$temp = explode('\',\'',$res->Type);
//temp is an array with as much elements as the enum

while ($temp)
print array_pop($temp);

This way is much more easier using the elements since they are elements
of an array. Cleaver isn't it?

Mar 17 '06 #1
0 1099

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Pjotr Wedersteers | last post: by
26 posts views Thread by Harrie | last post: by
6 posts views Thread by Chris Leuty | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.