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:
#2

[eluser]Mareshal[/eluser]
[quote author="Stephen G" date="1268747447"]Hi Tongue
I am new to code ignitor, and PHP[/quote]

Off topic: I don't think you are working with CodeIGNITOR, is CodeIgniter in my knowledge.
On topic: If you are new to PHP, don't work with CodeIgniter from start. Better try to make easy tasks using simple PHP, see how they work, then move to CI. I had 2 years PHP experience when I started CI.

To loop between columns, try this: http://ellislab.com/codeigniter/user-gui...forge.html




Theme © iAndrew 2016 - Forum software by © MyBB