您好我使用select到我的项目。我从数据库中获取值。现在,如果我选择值转到另一页。但我无法做到这一点。
以下是我的选择代码:
'x' in type(m).__dict__
答案 0 :(得分:0)
好的,这是我的更正代码:
<label for="month">Month:</label>
<select name="month" type="text">
<option value="">--Choose Month--</option>
<?php
$dbHost ="localhost";
$dbAdi ="futurk_etkin";
$dbSifre ="etkin";
$dbData ="futurk_etkin";
// Create connection
$conn = new mysqli($dbHost, $dbAdi, $dbSifre, $dbData);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM table";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
if(isset($_POST["month"])) {
$optionSelected = "selected='selected'";
}else{
$optionSelected = "";
}
$MonthSet = "<option value='../../index.php' ".$optionSelected.">".$row["month"]."</option>";
echo $MonthSet;
}
}
$conn->close();
$selectOption = $_GET['month'];
echo "Your Choose:" .$selectOption;
?>
</select>
p.s让我知道它是否适合你,否则,如果没有,所以我可以在这里更新这个答案。 :)