title: UPDATE MySQL table using php loop
body: <p>Given the following mysql table, here I attach a sample:</p>
  
  <pre><code>+------+-----------+-------------+-------------------+
  | f_id | sub_id    | field_name  | field_val         |
  +------+-----------+-------------+-------------------+
  | 256  | 15        | Email:      | pete@abba.com     |
  | 257  | 15        | Name:       | Peter             |
  | 258  | 15        | Page:       | home/contact.html |
  | 259  | 16        | Email:      | john@xyz.com      |
  | 260  | 16        | Name:       | John              |
  | 261  | 16        | Page:       | page-example.html |
  | 262  | 17        | Email:      | mary@cococo.net   |
  | 263  | 17        | Name:       | Mary              |
  | 264  | 17        | Page:       | home/service.html |
  +------+-----------+-------------+-------------------+
  </code></pre>
  
  <p>I need to evaluate the <code>field_val</code> value when <code>field_name LIKE 'Email:'</code> and get the company name, comparing the email extension using an existing array that stores the relation between mail extensions and company names:</p>
  
  <pre><code>array(
  'abba.com' =&gt; 'Abba INC.',
  'xyz.com' =&gt; 'Xyz S.A.',
  'cococo.net' =&gt; 'Cococo Ltd.'
  );
  </code></pre>
  
  <p>And convert the first table in the following table:</p>
  
  <pre><code>+------+-----------+-------------+-------------------+
  | f_id | sub_id    | field_name  | field_val         |
  +------+-----------+-------------+-------------------+
  | 256  | 15        | Email:      | pete@abba.com     |
  | 257  | 15        | Name:       | Peter             |
  | 258  | 15        | Company:    | Abba INC.         |
  | 259  | 16        | Email:      | john@xyz.com      |
  | 260  | 16        | Name:       | John              |
  | 261  | 16        | Company:    | Xyz S.A.          |
  | 262  | 17        | Email:      | mary@cococo.net   |
  | 263  | 17        | Name:       | Mary              |
  | 264  | 17        | Company:    | Cococo Ltd.       |
  +------+-----------+-------------+-------------------+
  </code></pre>
  
  <p>So, I have to change the <code>field_name</code> value of <code>Page:</code> to <code>Company:</code>, without changing <code>f_id</code>, and assign the <code>field_val</code> corresponding value, obtained through the mentioned array.</p>
  
  <p>Thanks.</p>