Click here to Skip to main content
15,878,048 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i trying to filter for product search. But not working i retrive data from backend.
Below my code what i tryed.

What I have tried:

Product show:

PHP
<div class="position-relative filter_product results">                        
	<?php
	$sql = "SELECT * FROM wm_products";
	$result = $conn->query($sql);
	if($result->num_rows > 0){
		while($row = $result->fetch_assoc()){
			?>
			<!-- start team item -->
			<div class="col-md-4 padding-15px-lr team-block text-left team-style-1 md-margin-70px-bottom wow fadeInUp">
				<div class="agileinfo_new_products_grid">
					<div class="agile_ecommerce_tab_left agileinfo_new_products_grid1">
						<div class="hs-wrapper hs-wrapper1">
							<img src="products_images/<?php echo $row['pro_img']; ?>" alt=" " class="img-responsive" />
							<img src="products_images/<?php echo $row['pro_img']; ?>" alt=" " class="img-responsive" />
							
							<div class="w3_hs_bottom w3_hs_bottom_sub">
								<ul>
									<li>										
										<a href="" class="prod_detail" data-toggle="modal" data-target="#product_popup" dataid="<?php echo $row['pro_id']; ?>">
										<span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>
										</a>
									</li>
								</ul>
							</div>
						</div>
						<p class="product-name"><a href="#."><?php echo $row['pro_name']; ?></a></p>
						<div class="simpleCart_shelfItem">
							<p>Rs. <?php echo $row['pro_price'];?></p>
							<p><a href="" class="button add_to_cart_button" dataid="<?php echo $row['pro_id']; ?>"> Add to cart</a></p>
						</div>
					</div>
				</div>
			</div>
			<!-- end team item -->  
			<?php
		}
	}
	?>                           
</div>


Category to filter
<ul class="list-style-6 margin-50px-bottom text-small tags">
    <?php 									
	$query=mysqli_query($conn,"SELECT * FROM wm_occasion ORDER BY occasion_name ASC");
	if(mysqli_num_rows($query) > 0){
		while($row = mysqli_fetch_assoc($query)){
			?>
			<li>			
				<input type="checkbox" name="<?php echo $row["occasion_id"];?>" value="<?php echo $row["occasion_id"];?>" dataid="<?php echo $row["occasion_id"];?>" class="filter_occasion"  id="<?php echo $row["occasion_id"];?>"><label for="<?php echo $row["occasion_id"];?>"><?php echo $row['occasion_name']; ?></label>
			
			</li>
			<?php 
		}
	}
	?>								
</ul> 


here my js to filter
$(document).ready(function () {
	$('ul.tags').find('input:checkbox').live('click', function () {
		if ($(this).prop("checked")) {
			$('.results > div').toggle('show');
			$('ul.tags').find('input:checked').each(function () {
				$('.results > div.' + $(this).attr('rel')).toggle('show');
			});
		} else{
			$('.results > div').show();
		}
	});
}); 
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900