title: Get selected values from combo box PHP Codeigniter
body: <p>Hello I am creating a <strong>Web GIS</strong> with Codeigniter framework.
  I am just facing a problem while Updating Location Data.</p>
  
  <p>On my database I have table "location_category" with field: id_category (primarykey), name_category, icon_category</p>
  
  <p>And also table "location" with field: id_location (primarykey), name_location, id_category (foreignkey to table location_category), lat, long.</p>
  
  <p>So, the problem is where I updated a data location on it's category combobox, it doesn't pointed to selected location category.</p>
  
  <p>This is <strong>View</strong> of location_edit.php</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="form-group"&gt;
                    &lt;label&gt;Edit Location&lt;/label&gt;
                    &lt;br/&gt;
                     &lt;input name="id_location" type="hidden" value="&lt;?=$d['id_location'] ?&gt;"&gt;
                    &lt;select name="location_category" class="form-control select2" style="width: 40%;"&gt;
                     &lt;-- The problem should be here --&gt;
                      &lt;?php foreach ($dj-&gt;result() as $r) {
                        echo "&lt;option value='$d-&gt;id_category'&gt;$r-&gt;nama_category&lt;/option&gt;";
                      } ?&gt;
                    &lt;/select&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                    &lt;label&gt;Name&lt;/label&gt;
                    &lt;input name="name_location" type="text" id="name_location" class="form-control" style="width:40%;" value="&lt;?=$d['name_location'] ?&gt;" required=""&gt;
                  &lt;/div&gt;
  &lt;div class="form-group"&gt;
                    &lt;label&gt;Latitude&lt;/label&gt;
                    &lt;input name="latitude" type="text" id="latitude" class="form-control" style="width:40%;" value="&lt;?=$d['latitude'] ?&gt;" required=""&gt;
                  &lt;/div&gt;
                   &lt;div class="form-group"&gt;
                    &lt;label&gt;Longitude&lt;/label&gt;
                    &lt;input name="longitude" type="text" id="longitude" class="form-control" style="width:40%;" value="&lt;?=$d['longitude'] ?&gt;" required=""&gt;
                  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is <strong>Controller</strong> of location_edit.php</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>public function Location_edit($id)
   {
    $data['c'] = $this-&gt;db-&gt;get('location_category');
    $data['d'] = $this-&gt;db-&gt;get_where('location',array('id_location'=&gt;$id))-&gt;row_array();
    $data['dj'] = $this-&gt;db-&gt;query("SELECT l.id_location, l.id_category, k.name_category FROM location as l, category as c WHERE l.id_category=c.id_category");
    $this-&gt;template-&gt;load('back-end/_template','back-end/_location_edit',$data);
   }</code></pre>
  </div>
  </div>
  </p>