title: Auto populate based on dropdown selected, need help
body: <p>How can I auto populate the data from db by dropdown selected?
  and my dropdown result already appear as well, the code as following:</p>
  
  <pre><code>&lt;?php
      echo '&lt;tr&gt;
      &lt;td&gt;'.$customer.'&lt;/td&gt;
      &lt;td&gt;&lt;select name="customer_id"&gt;';
  
      foreach ($customers as $customer) {
          if ($customer['customer_id'] == $customer_id) {
              echo '&lt;option value="'.$customer['customer_id'].'" selected="selected"&gt;'.$customer['name'].'&lt;/option&gt;';
          } else {
              echo '&lt;option value="'.$customer['customer_id'].'"&gt;'.$customer['name'].'&lt;/option&gt;';
          }
      }
      echo '&lt;/select&gt;
          &lt;/td&gt;
      &lt;/tr&gt;';
  ?&gt;
  </code></pre>
  
  <p>and the result of dropdown above listed as</p>
  
  <ul>
  <li>admin</li>
  <li>customer1</li>
  <li>FREE</li>
  </ul>
  
  <p>loaded from following db</p>
  
  <pre><code>INSERT INTO `my_customer` (`customer_id`, `name`, `firstname`, `lastname`) VALUES
  (8, 'admin', '', ''),
  (6, 'customer1', 'ok', ''),
  (7, 'FREE', 'marj', 'om');
  </code></pre>
  
  <p>so whenever dropdown selected i want the all data below: </p>
  
  <pre><code>&lt;tr&gt;
  &lt;td&gt;&lt;?php echo $firstname; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $lastname; ?&gt;&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>also auto populate, it seem need javascript/ajax/jquery to fixed it, I was Wondering if someone could help me, and thanks in advance</p>
  
  <hr>
  
  <p><strong>Addtion</strong> JSON CALL</p>
  
  <p>I have the json call already as following:
  (let say this placed at customer.php with url <strong>index.php?p=page/customer</strong>)</p>
  
  <pre><code>public function customers() {
      $this-&gt;load-&gt;model('account/customer');
      if (isset($this-&gt;request-&gt;get['customer_id'])) {
          $customer_id = $this-&gt;request-&gt;get['customer_id'];
      } else {
          $customer_id = 0;
      }
  
      $customer_data = array();
      $results = $this-&gt;account_customer-&gt;getCustomer($customer_id);
      foreach ($results as $result) {
          $customer_data[] = array(
              'customer_id' =&gt; $result['customer_id'],
              'name'       =&gt; $result['name'],
              'firstname'       =&gt; $result['firstname'],
              'lastname'      =&gt; $result['lastname']
          );
      }
  
      $this-&gt;load-&gt;library('json');
      $this-&gt;response-&gt;setOutput(Json::encode($customer_data));
  }
  </code></pre>
  
  <p>and the db </p>
  
  <pre><code>public function getCustomer($customer_id) {
      $query = $this-&gt;db-&gt;query("SELECT DISTINCT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int)$customer_id . "'");
      return $query-&gt;row;
  }
  </code></pre>