Manuelo Zumbadze Manuelo Zumbadze - 1 year ago 74
PHP Question

How to insert HTML select value as text in MySQL via PHP

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
in PHP and then insert value in MySQL.

For example: Someone choose Tbilisi (i.e.
) 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...

Answer Source

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']];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download