Jump to content

Live search com checkboxes ajax mysql

Recommended Posts


Boa tarde, gostaria de uma pequena ajuda.. Estou a desenvolver um website de streaming de videos/filmes e estou com dificuldade a filtrar pesquisas multiplas...


Tenho checkboxes com todas as categorias e a minha ideia era que ao selecionar uma checkbox, mudava a query e assim sucessivamente, mesmo tendo varias checkboxes selecionadas..

while ($gInfo = $genres->fetch(PDO::FETCH_ASSOC)) {
  if($gInfo['visible'] !== "no")
	<input type="checkbox" id="<?php echo $gInfo['genreid']; ?>" name="categoria" value="<?php echo $gInfo['genreid']; ?>"> <label for="<?php echo $gInfo['genreid']; ?>"><?php echo $gInfo['genre']; ?></label>




Ate agora so consegui isto: que e apenas para pesquisar todos os filmes:



		var movie = $(this).val();
			type: 'GET',
			url: 'search.php',
			data: 'movie=' + movie,
			success: function(data){


if( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && ( $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) )
	// Creating function
	function search($text){
		// Filtering data
		$text = htmlspecialchars($text);
		// Preparing mysql to fetch data
		$get_name = $conn->prepare("SELECT * FROM movies WHERE titleEN LIKE concat('%', :titleEN, '%')");
		$get_name->execute(array(':titleEN' => $text));
		$data = $get_name->fetchAll();
			foreach ($data as $mInfo) {?>
					<a href="movie.php?title=<?php echo $mInfo['titleEN']; ?>&m=<?php echo $mInfo['imdbID']; ?>" target="_self">
						<img src="assets/images/poster/<?php echo $mInfo['poster']; ?>.jpg" alt="<?php echo $mInfo['titleEN']; ?>">
		} else {
			echo "No records";

	// call the search function with the data sent from Ajax

} else {
    echo "Restricted access";


Sera que alguem me poderia dar uma ajuda? Desde ja obrigado

Edited by shizzzzzzzz

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.