我正在尝试创建一个从 10 到 90 的下拉框,我希望每个值代表介于两者之间的数字(因此 10 将包含 11、12、13、14 等等)。因此,如果用户单击 10,它将显示数据库中范围从 10 到 19 的任何条目,而不仅仅是其中带有“10”的条目。
是否可以在选项标签中添加多个值?这是我到目前为止所尝试的。
HTML:
<body>
<form action="form3.php" method="post">
<label for ="description">Description:</label>
<input type="text" name="descrip" /><br />
<label for="trayheight">Height: </label>
<select name="trayheight">
<option value="">All</option>
<option value="10">10</option>
<option value="[20:21:22:23:24:25:26:27:28:29]">20</option>
<option value="30">30</option>
<option value="40">40</option>
<option value="50">50</option>
<option value="60">60</option>
<option value="70">70</option>
<option value="80">10</option>
<option value="90">90</option>
</select><br />
<label for="trayrange">Trayrange: </label>
<select name="trayrange">
<option value="">All</option>
<option value="BBQ">BBQ</option>
<option value="Dessert">Dessert</option>
<option value="Display">Display</option>
<option value="Meat">Meat</option>
<option value="Microwave">Microwave</option>
<option value="Party">Party</option>
<option value="Salad/Wet Pasta">Salad/Wet Pasta</option>
<option value="Snacks">Snacks</option>
<option value="Standard">Standard</option>
</select><br />
<label for ="traytype">Traytype: </label>
<select name="traytype">
<option value="">All</option>
<option value="Open">Open</option>
<option value="Cavitised">Cavitised</option>
<option value="Lid">Lid</option>
<option value="Tray">Tray</option>
<option value="Coallition">Coallition</option>
<option value="Bowl">Bowl</option>
<option value="Hinge pack">Hinge pack</option>
<option value="Pot">Pot</option>
<option value="Base & Lid">Base and Lid</option>
<option value="Rectangular">Rectangular</option>
<option value="Specalist">Specialist</option>
</select><br />
<label for="trayshape">Trayshape: </label>
<select name="trayshape">
<option value="">All</option>
<option value="Rectangular">Rectangular</option>
<option value="Oval">Oval</option>
<option value="Square">Square</option>
<option value="Insert">Insert</option>
<option value="Round">Round</option>
<option value="Open">Open</option>
</select><br />
<input type="submit" value="Submit" />
</form>
</body>
PHP:
<body>
<?php
$con = mysql_connect ("localhost", "root", "");
mysql_select_db ("delyn_db", $con);
if (!$con)
{
die ("Could not connect: " . mysql_error());
}
$descrip = mysql_real_escape_string($_POST['descrip']);
$width = mysql_real_escape_string($_POST['width']);
$depth = mysql_real_escape_string($_POST['depth']);
$varHeight= mysql_real_escape_string($_POST['trayheight']);
$varRange = mysql_real_escape_string($_POST['trayrange']);
$varType = mysql_real_escape_string($_POST['traytype']);
$varShape = mysql_real_escape_string($_POST['trayshape']);
$varImage = mysql_real_escape_string($_POST['imagename']);
$sql = "SELECT * FROM delyn WHERE
description LIKE '%".$descrip."%'
AND trayheight LIKE '%".$varHeight."%'
AND trayrange LIKE '%".$varRange."%'
AND traytype LIKE '%".$varType."%'
AND trayshape LIKE '%".$varShape."%'";
$r_query = mysql_query($sql);
while ($row = mysql_fetch_array($r_query))
{
echo '<br /> <img src=" '. $row['imagename'] . '" width="180" length="100">';
echo '<br /> Tool Code: '. $row['toolcode'];
echo '<br /> Description: '. $row['description'];
echo '<br /> Tray range: '. $row['trayrange'];
echo '<br /> Tray type: '. $row['traytype'];
echo '<br /> Tray size: '. $row['traysize'];
echo '<br /> Tray shape: '. $row['trayshape'] . '<br />' . '<br />';
}
if (mysql_num_rows($r_query) <= 0){
echo 'No results match your search, please try again';
}
?>
</body>
提前感谢任何可以提供帮助的人:)