0

Hi I'm really new to this and i'm trying to get data from an array for a drop down box, here is what I have tried but all that shows in the box is the word array. Anyone able to help?

</form>

1
  • Thanks for the help I will take a look at them articles, do you know how I would then take the data that was chosen and to display on a response page everything I do it doesn't work Commented Jan 12, 2014 at 19:54

1 Answer 1

1

You need to loop through the array not just print it.

<select name="newspaper">
    <?php foreach($newspaper as $index => $item) { ?>
        <option value="<?php echo $index; ?>"><?php echo $item; ?></option>
    <?php } ?>
</select>

You should definitely look up arrays and read more about them.

https://www.php.net/manual/en/language.types.array.php

http://www.php.net/manual/en/control-structures.foreach.php

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the help I will take a look at them articles, do you know how I would then take the data that was chosen and to display on a response page everything I do it doesn't work

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.