Jump to content

Recommended Posts

Posted (edited)

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..

<?php
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>
 
	<?php}
}
?>

 

download.png

 

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

 

INDEX.PHP

<script>
$(document).ready(function(e){
	$("#search").keyup(function(){
		$("#results").show();
		var movie = $(this).val();
		$.ajax({
			type: 'GET',
			url: 'search.php',
			data: 'movie=' + movie,
			success: function(data){
				$("#results").html(data);
			}
		});
	})
});
</script>


SEARCH.PHP:

<?php
if( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && ( $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) )
{
	
	// Creating function
	function search($text){
	require_once("assets/includes/system/conn.php");
		
		// 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();
		
		if($data){
			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']; ?>">
	
					</a>
					
			<?php
			}
		} else {
			echo "No records";
		}
	}

	// call the search function with the data sent from Ajax
	search($_GET['movie']);

} else {
    echo "Restricted access";
} 
?>

 

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

Edited by shizzzzzzzz

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.