php: getting value of php variable in foreach loop and passing it to a html "form-group" view -


i new php , don't know doing yet. got array of values passed controller of view ($positions). want iterate through , each value in array , have value show in html drop-down menu (form-group). trying echo statement inside loop, don't work, , kinda lost on how this.

<div id="middle"> <form action="sell.php" method="post">     <fieldset>         <div class="form-group">             <select class="form-control" name="symbol">                 <option value=""> </option>                      <?php                     foreach ($positions $position)                     {                     $symbol = $position["symbol"];                     echo "<option value='app'>$_post["symbol"]</option>";                       //echo $_post["symbol"];                     //print $_post["symbol"];              //echo "<h1>hello " . $_post["symbol"] . "</h1>"; 

string concatenation . allows combination of php variables ($position) strings (<option>)

<?php      foreach ($positions $position) {                          echo "<option value='". $position["symbol"] ."'>" . $position["symbol"] . "</option>";     }  ?>     

anything within quotes string, "string" . $variable . "string" concatenation taking value of php variable , combining strings.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -