You are here: Populating form item from SQL enum set Rev#2 « PHP Programming Language « IT news, forums, messages
Populating form item from SQL enum set Rev#2

Posted by Duderino82 on 03/18/06 00:05

$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?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация