-2
這裏是我的HTML代碼:獲得PHP選擇值沒有SQL命令
<form method = "get" action = "PHPFile.php">
Type:<select name = "type">
<option value = "1">1</option>
<option value = "1">2</option>
<option value = "1">3</option>
</select>
Your Type:<input type = "text" name = "yourType" value = "$varType;">
Fee:<input type = "text" name = "fee" value = "$varFee;">
</form>
我想我的選擇「類型」的值,並將其傳遞給我的文本框「yourType」。
而且每種類型的選項具有相應的費用:
對於類型1 = 250
類型2 = 90
類型3 = 90
這是我的PHP代碼:
<?php
$varType = $_GET("type");
if($varType == 1){
$varFee = 250;
}
else {
$varFee = 90;
}
?>
但我總獲取$ varType的值時出現解析錯誤
也許是時候閱讀手冊了?訪問數組是通過'[]' –
完成的。使用GET的正確方法是$ _GET ['type']。你不應該使用()。 –