0

I have this array data on my form.i used a controller to display value list.if i want to store it to database,using value of 1,and when i want to edit the data,it shows the text on dropdown.for example :

$data['material'] = array(
                          '1'=> 'Plastic',
                          '2'=> 'Rubber',
                          '3'=> 'Metal',
                         );
<select>
    <?php foreach($material as $value)
          {
            echo '<option value=".$value['....']."'>'.$value['....'].'</option>
          }
</select>

any tips for doing this ? Thank you

1 Answer 1

3

You have associated array of key/value pairs.So try like below.

foreach($material as $key=>$value)
          {
            echo "<option value="'.$key.'">".$value."</option>";
          }
Sign up to request clarification or add additional context in comments.

1 Comment

wait i'll try..i'll let you now when i've make the changes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.