I’m trying to make a multi-lingual dictionary with one main language. I would like to use radio buttons to change languages (and the query in php)
My idea is to have for example 3 radio-buttons: -English, -German, -Spanish. That is to change languages/queries.
Now I have such a code (in 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>
That was jquery script to get instantly results. And the search form in div:
<div id='container'>
<div id='search-box'>
<form id='search-form'>
<input type='text' id='input-text' name='s' value=''/>
</form>
</div>
In 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'];
?>
So my idea is: if -English is on, than query must be:
$q = "SELECT * FROM lauk_pamed WHERE diakr LIKE '%".$search_term. "%'or english LIKE '%" .$search_term. "%' ORDER BY words LIMIT 21";
if -German is on, than query must be:
$q = "SELECT * FROM lauk_pamed WHERE diakr LIKE '%".$search_term. "%'or german LIKE '%" .$search_term. "%' ORDER BY words LIMIT 21";
And so on. How could I do it using radio-buttons?
In your HTML do something like this:
And then in PHP you can get the string and the language like this:
If you want the form to auto submit when you click on a different language you can do this in your JS: