note 26932 added to function.mysql-query
| From: | claude_minette at hotmail dot com | Date: | Mon, 18 Nov 2002 10:15:16 +0000 |
| Subject: | note 26932 added to function.mysql-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-39627@lists.php.net to get a copy of this message | ||
I nedded to have a select box containing the fields of an ENUM in a MySQL table.
Use this if you need it too. it may be useful. Be sure to be connected and use $table to choose the
table you want to describe.
$table="Ma_table"
$describe=mysql_query("describe $table");
while ($ligne=mysql_fetch_array($describe)){
extract($ligne);
if (substr($Type,0,4)=='enum'){
echo $Type;
$liste=substr($Type,5,strlen($Type));
$liste=substr($liste,0,(strlen($liste)-2));
$enums=explode(',',$liste);
if (sizeof($enums)>0){
echo "<select name='enum'>\n";
for ($i=0; $i<sizeof($enums);$i++){
$elem=strtr($enums[$i],"'"," ");
echo "<option
value='".$elem."'>".$elem."</option>\n";
}
echo "</select>";
}
}
}
Hope it will help...
Some improvements can bee done, if you do, please mail me the improvements you've done...
Min's
--
http://www.php.net/manual/en/function.mysql-query.php
http://master.php.net/manage/user-notes.php?action=edit+26932
http://master.php.net/manage/user-notes.php?action=delete+26932
http://master.php.net/manage/user-notes.php?action=reject+26932