-1

I know this is an error staring me blank in the face but for the life of me i cannot see it. any idea why? Any suggestions would be appreciated.

$locations = Select('SELECT location_id, venue_city FROM location');

echo '<select style="width:100px;">' .
        foreach($locations as $location)
        { . '<option value="' .  $location['location_id'] .'">'. $location['venue_city'] . '</option>' . } .
     '</select>';
  • actually .. whats `Select()` do ?? its not a core php function –  Aug 01 '16 at 21:47
  • 3
    You can't have a foreach loop inside a concatenation. You may want to look at `.=` concatenating inside the foreach loop, not the other way around. – Rizier123 Aug 01 '16 at 21:48
  • 'Select()' is a function from a library, it does all the connection to database for you. that way every time you make a new page you don't have to copy in connection strings and stuff. Also noted for the '.=' – Mitchell Aug 01 '16 at 21:56
  • well for the next question remember we don't know what libraries you are using. –  Aug 01 '16 at 22:04

1 Answers1

-2

Foreach only accepts array values. I believe you are calling it with a string value.

doug
  • 197
  • 2
  • 3