Welcome Guest, Not a member yet? Register   Sign In
Getting array from database, displaying values in inputs
#4

[eluser]dallen33[/eluser]
I figured it out, so thought I'd post my solution incase it can help someone! Thanks for your help guys!
Code:
if ($contacts):
    echo form_open($this->uri->uri_string(), array('id' => 'add_client'));
        for ($i = 0; $i <= count($contacts)-1; $i++):
            echo '&lt;input type="text" name="contacts[]" value="'.$contacts[$i].'" /&gt;';
        endfor;
        if (count($contacts) < $this->config->item('book_proof_contacts', 'booking')):
            for ($i = count($contacts); $i <= $this->config->item('book_proof_contacts', 'booking')-1; $i++):
                echo '&lt;input type="text" name="contacts[]" value="" /&gt;';
            endfor;
        endif;
    endif;
I have a -1 in my loops because there's an extra space at the end of my database field that doesn't need to be there.


Messages In This Thread
Getting array from database, displaying values in inputs - by El Forum - 05-21-2009, 09:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB