我想在我的网站上使用多个条件/高级搜索选项,但是我不知道该怎么做。搜索应包括单词,下拉列表和复选框。
我已经从MySQL数据库中列出了所有信息(https://rajalassie.net/tietokantakokeilu/kanta.php),但是我想创建一个搜索表单,一个人可以选择她/他想看到的功能(https://rajalassie.net/tietokantakokeilu/etsi.php )
我对此绝对是新手,我什至不知道从哪里开始,所以如果有人能逐字告诉我我应该如何使表格生效,我将非常感激。我试图从这里的旧主题/帖子中获得一些提示,但是我无法适应这些信息。
不确定是否有人需要它,但这是我从数据库调用所有信息时使用的代码。
$sql = "SELECT * FROM dogs WHERE aktiivinen='1' ORDER BY country, name";
$haku = $yhteys->query($sql);
if ($haku->num_rows > 0) {
// output data of each row
while($info = $haku->fetch_assoc()) {
Print "<center><table cellspacing=\"4\"><tr><td colspan=\"4\">".$info["name"].", ".$info["gender"]."</td>";
Print "<td rowspan=\"3\">Source: ";
if ($info["lahde"] == 'owner') {echo "owner";}
elseif ($info["lahde"] == 'breeder') {echo "breeder";}
elseif ($info["lahde"] == 'muu') {echo "another database";}
elseif ($info["lahde"] == 'joku') {echo "another source";}
Print "<br />Affected: ";
if ($info["nivel1"] == 'shoulder') {echo "shoulder";}
elseif ($info["nivel1"] == 'elbow') {echo "elbow";}
elseif ($info["nivel1"] == 'hock') {echo "hock";}
elseif ($info["nivel1"] == 'other') {echo "other";}
Print "</td></tr><tr>";
Print "<td colspan=\"2\" width=\"40%\">".$info["sire"]."</td>";
Print "<td colspan=\"2\" width=\"40%\">".$info["dam"]."</td></tr><tr>";
Print "<td width=\"20%\">".$info["siresire"]."</td>";
Print "<td width=\"20%\">".$info["siredam"]."</td>";
Print "<td width=\"20%\">".$info["damsire"]."</td>";
Print "<td width=\"20%\">".$info["damdam"]."</td></tr></table></center>";
这是表单代码
<form action="/action_page.php" method="get" id="search">
<table width="100%" border="1">
<tr>
<td>Dog's name or reg number</td>
<td>County dog lives in</td>
<td width="25%">gender</td>
</tr>
<tr>
<td width="25%"><input name="name" type="text" id="name" size="40"></td>
<td>
<form action="/action_page.php">
<select name="country">
<option value="all-countries">all countries</option>
<option value="fi">Finland</option>
<option value="se">Sweden</option>
<option value="no">Norway</option>
<option value="dk">Denmark</option>
</select>
</form>
</td>
<td>
<label><input name="sex" type="checkbox" id="male" value="male">male</label>
<label><input name="sex" type="checkbox" id="female" value="female">female</label>
</td>
</tr>
<tr>
<td colspan="3">Affected joint</td>
</tr>
<tr>
<td colspan="3">
Shoulder
<label><input name="sd" type="checkbox" id="sd-left" value="sd-left">left</label>
<label><input name="sd" type="checkbox" id="sd-right" value="sd-right">right</label>
<label><input name="sd" type="checkbox" id="sd-both" value="sd-both">both</label> <br />
Elbow
<label><input name="elbow" type="checkbox" id="elbow-left" value="elbow-left">left</label>
<label><input name="elbow" type="checkbox" id="elbow-right" value="elbow-right">right</label>
<label><input name="elbow" type="checkbox" id="elbow-both" value="elbow-both">both</label> <br />
Hock
<label><input name="hock" type="checkbox" id="hock-left" value="hock-left">left</label>
<label><input name="hock" type="checkbox" id="hock-right" value="hock-right">right</label>
<label><input name="hock" type="checkbox" id="hock-both" value="hock-both">both</label> <br />
Else, where?
<input name="else" type="text" id="else" size="30">
</td>
</tr>
</table>
</form>
<button type="submit" form="search" value="Submit">Submit</button>