lundi 23 mars 2015

Using AJAX, MYSQL, PHP for dynamic filtering

In a nutshell, this is how the results are currently being populated:



$get_crs_mysqli = "select * from courses where course_title like '%" . $_SESSION['userSearch'] . "%' AND course_date1 >= CURRENT_DATE() ORDER BY course_date1 ASC LIMIT $position, $item_per_page";

$get_crs=mysqli_query($con, $get_crs_mysqli);


However, I would like to incorporate checkboxes into it. Where I have various checkbox on the sidebar, and I would want that results are dynimically updated as the check box are checked.


Let's start with just one group of checkbox:



//getting duration
function getDuration(){
global $con;
$get_dur = "select * from duration";
$run_dur = mysqli_query($con, $get_dur);

while ($row_dur=mysqli_fetch_array($run_dur)){
$dur_id = $row_dur['dur_id'];
$dur_title = $row_dur['dur_title'];


echo "<a href='searchPage.php?dur=$dur_id' id='liSpacing'><label id='labelSearch'><input type='checkbox' name='checkbox' value='value'>&nbsp;$dur_title</label></a><br />";



}
}


In this one it populates the duration of the course from 1 - 5, hence 5 checkbox are displayed, and I would want if the user checkbox on 3 then it only shows course with a course duration of 3.


I have no clue how to pull this off, and is truly confused.


Just imagine





Aucun commentaire:

Enregistrer un commentaire