Viewing File: /home/webrbaew/kitothecandytea.com/ajax.php

<?php
	include "admin/database.php";
	include "functions.php";
	if (isset($_POST['get_reviews'])) {
		$product_id = $_POST['product_id'];
		$reviews_limit = $_POST['reviews_limit'];
		$reviews_offset = $_POST['reviews_offset'];
		$review_res = mysqli_query($con, "SELECT * FROM review WHERE product_id=$product_id ORDER BY review_time DESC LIMIT $reviews_limit OFFSET $reviews_offset");
		if (mysqli_num_rows($review_res)>0) {
			while ($review_row = mysqli_fetch_array($review_res)) {
				show_review($review_row);
			}
		}
		$reviews_offset += $reviews_limit;
		$next_res = mysqli_query($con, "SELECT * FROM review WHERE product_id=$product_id ORDER BY review_time DESC LIMIT $reviews_limit OFFSET $reviews_offset");
		$next_count = mysqli_num_rows($next_res);
		if ($next_count>0) {
			?>
				<button class="btn btn-primary" onclick="this.style.display='none';get_reviews();">Show <?php echo $next_count; ?> more review<?php if ($next_count>1) echo 's'; ?></button>
			<?php
		}
	}
	
	if(isset($_POST['update_cart_quantity'])){
		$cart_id = $_POST['cart_id'];
		$cart_quantity = $_POST['cart_quantity'];
		mysqli_query($con, "UPDATE cart SET quantity=$cart_quantity WHERE id = $cart_id");
		exit();
	}
	
?>
Back to Directory File Manager