我正在尝试用一种主要语言制作多语言词典。我想使用单选按钮来更改语言(以及 php 中的查询) 我的想法是拥有例如 3 个单选按钮:-English、-German、-Spanish。那就是改变语言/查询。
现在我有这样一个代码(在 index.php 中):
<script type='text/javascript'>
$(function(){
$("form#search-form").submit(function(){
$("#results").fadeOut();
$.ajax({
type:"GET",
data: $(this).serialize(),
url: "search.php",
success: function(msg)
{
$("#results").html(msg);
$("#results").fadeIn();
}
});
return false;
});
});
</script>
那是 jquery 脚本,可以立即获得结果。以及 div 中的搜索表单:
<div id='container'>
<div id='search-box'>
<form id='search-form'>
<input type='text' id='input-text' name='s' value=''/>
</form>
</div>
在 search.php 中:
$q = "SELECT * FROM lauk_pamed WHERE diakr LIKE '%".$search_term. "%'or mask LIKE '%" .$search_term. "%' ORDER BY words LIMIT 21";
$r = mysql_query($q);
if(mysql_num_rows($r)==0)//no result found
{
echo "<div id='search-status'>Nothing was found</div>";
}
else //result found
{
echo "<ul>";
while($row = mysql_fetch_assoc($r))
{
$prus = str_ireplace($search_term, "".$search_term."", $row['wirds']);
$des = $row['descr'];
?>
所以我的想法是:如果 -English 打开,则查询必须是:
$q = "SELECT * FROM lauk_pamed WHERE diakr LIKE '%".$search_term. "%'or english LIKE '%" .$search_term. "%' ORDER BY words LIMIT 21";
如果 -German 打开,则查询必须是:
$q = "SELECT * FROM lauk_pamed WHERE diakr LIKE '%".$search_term. "%'or german LIKE '%" .$search_term. "%' ORDER BY words LIMIT 21";
等等。我怎么能使用单选按钮来做到这一点?