In my site there is a page where is shown the content of my database (the list of all the locals). I would like to let the user filter the research, so I would like that my query that show the resoults can be modified by checkboxes. If a user select Vegan in the checkbox, the page must show only vegan locals. I don't have a form for the checkboxes so I don't know hot to handle the input. I have two scripts: locals_page.php that is the main page with the filter boxes and table_generator.php that is a php script that do the query and retrieve the data, and show them into locals_page.php
I searched a lot to resolve this but I don't know how to start because I don't have a simple table for the resoults or a common form.
Maybe it's a generic question, but an help will be appreciated.
locals_page
<body>
<div class="container">
<div class="row">
<!--FILTERS PART-->
<div class="col-sm-3 col-md-3">
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne"><span class="glyphicon glyphicon-folder-close">
</span>Kitchen type</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in">
<div class="panel-body">
<table class="table">
<tr>
<td>
<input type="checkbox" name="Kebab" value="Kebab"> Kebab
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="Asiatic" value="Asiatic"> Asiatic
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="Vegan" value="Vegan"> Vegan
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo"><span class="glyphicon glyphicon-th">
</span>Local Type</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse">
<div class="panel-body">
<table class="table">
<tr>
<td>
<input type="checkbox" name="Restaurant" value="Restaurant"> Restaurant
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="Pub" value="Pub"> Pub
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<!--END FILTERS PART-->
<div class="col-sm-9 col-md-9">
<!--SCRIPT THAT GENERATE MY PAGE-->
<?php require_once('php\table_generator.php'); ?>
</div>
</div>
</div>
</body>
table_generator
<?php
echo'<section class="col-xs-12 col-sm-6 col-md-12">';
$sql = "SELECT nome_L, tipocucina_TC, wifi_L, tipolocale_TL, descrizione_L, indirizzo_L, fasciaprezzo_L, convenzione_L FROM locale l
JOIN tipocucina c On l.TipoCucina_L = c.IDtipocucina_TC
JOIN tipolocale t On l.TipoLocale_L = t.IDTipolocale_TL";
$result = mysqli_query($conn,$sql)or die(mysqli_error($conn));
while($row = mysqli_fetch_array($result))
{
$nome_Local = $row['nome_L'];
$descrizione_Local = $row['descrizione_L'];
$indirizzo_Local = $row['indirizzo_L'];
$tipocucina_Local = $row['tipocucina_TC'];
$tipolocale_Local = $row['tipolocale_TL'];
$wifi_Local = $row['wifi_L'];
$prezzo_Local = $row['fasciaprezzo_L'];
//Inizio article
echo'<article class="search-result row">
<div class="col-xs-12 col-sm-12 col-md-3">
<a class="thumbnail"><img src="http://ift.tt/2sUAu2D" alt="Lorem ipsum" /></a>
</div>
<div class="col-xs-12 col-sm-12 col-md-2" style="width: 18%;">
<ul class="meta-search">
<li><i class="fa fa-cutlery fa-lg"></i> <span>'.$tipocucina_Local.'</span></li>
<li><i class="fa fa-coffee fa-lg"></i> <span>'.$tipolocale_Local.'</span></li>
<li><i class="fa fa-coffee fa-lg"></i> <span>'.$wifi_Local.'</span></li>
<li><i class="fa fa-coffee fa-lg"></i> <span>'.$prezzo_Local.'</span></li>
</ul>
</div>
<div class="col-xs-12 col-sm-12 col-md-7 excerpet" style="width: 55%;">';
echo"<h3><a>".$nome_Local."</a></h3>";
echo'<i class="fa fa-compass"> </i>'.$indirizzo_Local.'</i>';
echo"<br>";
echo'<p class="local-description">'.$descrizione_Local.'</p>';
echo'
</div>
<span class="clearfix borda"></span>
</article>'; //Fine article
}
$conn->close();
?>
</section>
I don't know if javascript or ajax or jquery is needed. I don't ever know how to start. I hope my problem is understandable and that the code I put is helpful. Thank you so much in advice.
Aucun commentaire:
Enregistrer un commentaire