How do I populate these fields from existing data?

Posted by dmanexe on Stack Overflow See other posts from Stack Overflow or by dmanexe
Published on 2010-04-09T19:49:11Z Indexed on 2010/04/09 19:53 UTC
Read the original article Hit count: 298

Filed under:
|
|
|

I'm not sure how to make a few parts of my form to populate from data from an array I'm passing from the database.

First is this <select> object. The key estimate_lead_id in the database holds the value, and I want the dropdown to auto-select based on the value from the database.

<select name="estimate_lead_id">
    <? foreach($leads->result() as $lead) { ?>
        <option value="<?=$lead->id?>"><?=$lead->lead_name?></option>
    <? } ?>
</select>

Second (this is a little more complex), I have created a script that loops through and gets all of the items from each respective category.

What I can't get it to do though is loop through these items and only display the items in the estimate, and then fill the fields with the respective values from the database.

<?php foreach ($items['items_poolconcretedecking']->result() as $item) { ?>

    <input type="checkbox" name="measure[<?=$item->id?>][checkmark]" value="<?=$item->id?>">
    <input class="item_mult" value="" type="text" name="measure[<?=$item->id?>][quantity]" />

<?php } ?>

© Stack Overflow or respective owner

Related posts about html

Related posts about php