html - how can i get the selected value of dropdown list in php? -


i have seen several question can not find answer? add value dropdown through loop , want show value when select 1 value dropdown box .but can not find .

  $items[] = $file ;   echo '<select name="value">';   foreach($items $video){      echo  '<option value="' . $video . '">' . $video . '</option>' ;   }   echo '</select>';   $value = $_get['footage']; 

how can value when select value in dropdown box.

you need add html selected attribute <select>

$value = $_get['footage']; /* typo*/  $items[] = $file ;   echo '<select name="value">';   foreach($items $video){      $selected = ($value == $video) ? 'selected="selected"' : '';     echo  '<option value="' . $video . '"' . $selected . '>' . $video . '</option>' ;   }    echo'</select>'; 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

wso2esb - How to concatenate JSON array values in WSO2 ESB? -