在php中显示mysql枚举值 [英] displaying mysql enum values in php

查看:86
本文介绍了在php中显示mysql枚举值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好朋友,在插入和更新php页面时显示mysql枚举值的最佳方法是什么?

Hi friends what is the best way to show the mysql enum values while inserting and updating php page ?

name ENUM('small', 'medium', 'large')

实际上我是在要求这个. 我有一个数据库字段

edited: actually I was asking for this . I have a database field

 `color` enum('red','blue','green','white') DEFAULT NULL,

和php形式

<label for="color">Colors</label><br />
<input type="text" name="color" />

我如何在mysql数据库的php表单上显示枚举值?请帮助

How do i display enum value on the php form from mysql database? Please help

推荐答案

如果您有枚举字段,MySQL将为其返回字符串值,并且您也可以设置整数和字符串值.只需这样做:

mysql_query("select name from tablename");

将为您提供完整的标签,例如smallmediumlarge

will give you full labels like small or medium or large

您也可以使用类似的完整标签类似地更新它们:

And you can similarly update them too using full labels like this:

mysql_query("insert into tablename (name) values ('small')");

或类似这样的数值:

mysql_query("update tablename set name = 2");

这篇关于在php中显示mysql枚举值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆