How to get multiple values from a single <select> variable in HTML/PHP Codeigniter? -


<select id="selecterror" data-rel="chosen" name="emp_id" >     <?php foreach ($all_data $v) { ?>         <option value="<?= $v->emp_name."x".$v->emp_id; ?>">             <?= $v->emp_id; ?>         </option>     <?php } ?> </select> 

how send 2 values separated x in value database using codeigniter?

as there's lack of code controller, assuming mean pass data left of 'x' in value database @ same time data right of 'x', separate piece of data, , not including 'x'.

in controller, can do

$data_parts = explode('x', $this->input->post('emp_id'); 

this make $data_parts array, , can use information $data_parts[0] , $data_parts[1] pass database.

this work if first , last parts of data don't contain x. urge reconsider you're trying regards splitting of 'x', if means adding column database value of 2 items, plus x. index , use single value pass through search.

if you're looking insert 2 values alongside each other, should consider splitting them 2 different fields.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -