mysql数据库选择option,在MySQL数据库,PHP中存储下拉选项

I need to store the user selected option when chosen from my drop down select box, and when submitted in my form, store in my MYSQL database.

I already have information being stored and displayed fine, i am just trying to add more content now. I have tried using the same method, but i cant get it to store what i want.

The select drop down looks like this inside my form:

Difficulty:

easy

comfortable

hard

very hard

Hardest ride in the world!

and i am trying to send it using this:

$difficulty = mysql_real_escape_string($_POST['difficulty']);

Using this query:

$query = sprintf("INSERT INTO markers (difficulty) VALUES ('%s')", $difficulty);

When my table is set up as INT, 20, allow null, it stores 0 in the database.

and when i set it up VARCHAR, 20, allow null, it stores a blank field.

i want it to store whichever value the user chooses, i.e easy, hard, very hard etc.

Thanks very much

解决方案

$_POST['difficulty']

Would not hold a value as the SELECT has not been given a 'name'. Try

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值