Welcome Guest, Not a member yet? Register   Sign In
Looping through row columns values in a row?
#1

[eluser]Stephen G[/eluser]
Hi Tongue
I am new to code ignitor, and PHP :bug: :wow:

I am returning a set of results and loop through the results to print out a name value pair...
But i can not figure out what the best way to approach this? :red:

Here is my code... I want to do something like this??...


Code:
$this->db->where('id_fields', $row->id_forms_fields);
$data['field'] = $this->db->get('fields');

foreach($data['field']->result() as $field) {

  if($field->tagname == 'input') {
     foreach($field->result() as $item) {
        echo '"' $item['column'] . '" : "' $item['value'] . '"';        
     }
  }

This is what my table looks like

Code:
____________________________________________________________________________________
ID | TAGNAME |  TYPE | CLASS | ID               | VALUE | TABINDEX | NAME          |
=======================================================
1    | INPUT       | Text    |  text   | first_name | NULL    |   1              | first_name |
=======================================================
2   | INPUT       | Text    |  text   | last_name  | NULL    |   2              | last_name |
=======================================================

Is there a way to loop through each item in a row and print out the column name and value in either codeignitor or PHP?

Sincerely,
Steve :cheese:


Messages In This Thread
Looping through row columns values in a row? - by El Forum - 03-16-2010, 02:50 AM
Looping through row columns values in a row? - by El Forum - 03-16-2010, 03:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB