如何通过PHP在MySQL中插入HTML选择值 [英] How to insert HTML select value as text in MySQL via PHP

查看:316
本文介绍了如何通过PHP在MySQL中插入HTML选择值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个选择字段:
`

 < select class =large-fldid = regioniname =regionvalue => 

现在我需要,当我将这个选择'region'在PHP中,然后在MySQL中插入值。

例如:某人选择第比利斯(即 $ _ POST ['region'] = 775 ),此值(775)转至DB。我需要,PHP从这个值的HTML等价物中选择,而不是775中的数据库插入TBILISI ...
任何线索?

在此先感谢。 ..

解决方案

是775>第比利斯,776>库塔伊西在html中的静态数据?
您可以创建一个数组,例如

  $ regions = array('775'=>'Tbilisi', '776'=> '库塔伊斯'); 

以及在处理表单之前替换值:

  $ region = $ regions [$ _ POST ['region']]; 


I have this select field: `

<select class="large-fld" id="regioni" name="region" value="" >
<option value="0"  hidden>City...</option>
<option value="775">Tbilisi</option>
<option value="776">Kutaisi</option>
<option value="788">Batumi</option>
and so on...

Now I need, when I will call this selection 'region' in PHP and then insert value in MySQL.
For example: Someone choose Tbilisi (i.e. $_POST['region']=775) and this value (775) goes to DB. I need, PHP choose from HTML equivalent of this value and instead 775 in DB insert TBILISI...
any clue?

Thanks in advance...

解决方案

Are 775>Tbilisi, 776>Kutaisi static data in html? Simply you can create an array like

$regions = array('775'=>'Tbilisi','776'=>'Kutaisi');

and before processing form substitute values:

$region = $regions[$_POST['region']];

这篇关于如何通过PHP在MySQL中插入HTML选择值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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