PHP
PHP with Select Option
HiroDaegu
2021. 12. 30. 23:26
728x90
SMALL


<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WEB</title>
</head>
<style>
* {
text-align: center;
}
</style>
<body>
<h1>Select with PHP</h1>
<?php
$php = "php";
$num = 100;
?>
언어 선택
<select name="stack" id="stack">
<option value="">선택</option>
<option value="html" <?=($php == "html")? "selected" : " "?>>HTML</option>
<option value="php" <?=($php == "php")? "selected" : " "?>>PHP</option>
<option value="iOS" <?=($php =="iOS")? "selected" : " "?>>iOS</option>
<option value="android" <?=($php == "android")? "selected" : " "?>>Android</option>
</select>
숫자 선택
<select name="number" id="number">
<option value="">선택</option>
<option value="100" <?=($num == 100)? "selected" : " "?>>100</option>
<option value="200" <?=($num == 200)? "selected" : " "?>>200</option>
<option value="300" <?=($num == 300)? "selected" : " "?>>300</option>
<option value="400" <?=($num == 400)? "selected" : " "?>>400</option>
<option value="500" <?=($num == 500)? "selected" : " "?>>500</option>
</select>
</body>
</html>728x90
LIST