我正在尝试从我的 html 表单中将高度值(英尺/英寸)存储在我的 sql 数据库中,但到目前为止似乎无法正确生成它们。
我得到各种输出,例如:选择“5'02”产生 5
我尝试了不同的组合来转义引号。我也尝试过单引号和双引号等的不同配置......
到目前为止......没有任何运气。
“正确”的方法是什么?
注意:我正在使用 phpmyadmin 并且该列设置为 VARCHAR (20)
<?php
$height_selected = "$height";
$height_options = array(
"5'00",
"5'01",
"5'02",
"5'03",
"5'04",
"5'05",
"5'06",
"5'07",
"5'08",
"5'09",
"5'10",
"5'11",
"6'00",
"6'01",
"6'02",
"6'03",
"6'04",
"6'05",
"6'06",
"6'07",
"6'08",
"6'09",
"6'10",
"6'11",
"7'(+)");
echo "<select id='height' name='height'; >";
foreach($height_options as $height_option){
if($height_selected == $height_option) {
echo "<option selected='#selected' value='$height_option'>$height_option</option>";
}
else {
echo "<option value='$height_option'>$height_option</option>";
}
}
echo "</select>";
?>