【发布时间】:2014-07-08 12:25:44
【问题描述】:
所以我希望表单找到用户搜索的内容,然后通过下面的数组返回结果。这可能吗?我试过自己写php,但我一无所知。
<form action="result.php" method="post">
<input type="text" name="country" size="30" id="autocomplete-ajax" placeholder="Search for country, timezone or city and hit enter!" maxlength="30">
</form>
<?php
$countries = array(
"AD" => "Andorra",
"AE" => "United Arab Emirates",
"AF" => "Afghanistan",
"AG" => "Antiqua and Barbuda",
"AI" => "Anguilla",
"AL" => "Albania",
"ZZ" => "Unkown or Invalid Region");
if (isset($_POST[$countries[0]])){
echo "<p>Correct!</p>";
}
if (isset($_POST[$countries[1]])){
echo "<p>Correct2</p>";
}
?>
【问题讨论】:
-
我也有自动完成 js,我只是希望输入匹配用户使用我的 php 数组搜索的内容。