PHP functions with MySQL queries -
i'm making simple basketball stats plugin wordpress, , i'm using dropdown list lot. wanted make function don't know how pass arguments mysql. here's code:
function dropdown($tab, $option, $text){ $result = mysqli_query($con,'select * tab'); while($row = mysqli_fetch_array($result)){ echo "<option value=\""; echo $row['option'] . "\">" . $row['text']; echo "</option><br>"; } }
and use this:
dropdown("team", "team_id", "name");
i tried different quotation marks, dots etc doesn't seem work.
@edit know php syntax (some of it) , know how use it, don't know how pass $variables mysql query, , that's main problem.
try
function dropdown($team, $team_id, $name) { // use both 3 var want $result = mysqli_query($con,'select * team'); echo "<select>"; while($row = mysqli_fetch($result)){ echo "<option value=\""; echo $row['team_id'] . "\">" . $row['name']; echo "</option>"; } echo "</select>"; } dropdown("team", "team_id", "name");
Comments
Post a Comment