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
Post a Comment