问题描述
我有这个选择字段:
`
< select class =large-fldid = regioniname =regionvalue =>
< option value =775>第比利斯< / option>
< option value =776>库塔伊西< / option>
< option value =788>巴统< / option>
等等...
现在我需要,当我将这个选择'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选择值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!