Hello i am developing a project but getting an error i don't know why is this happening and i have tried everything i can.
please help me i am providing code below it requires 3 files to understand it so i am sending them:
index.php
<!-- Main Content-->
<div class="col-md-8">
<div class="row">
<h2 class="text-center">Featured Products</h2>
<?php while($product = mysqli_fetch_assoc($featured)): ?>
<div class="col-md-3">
<h4><?= $product['title']; ?></h4>
<img src="<?= $product['images']; ?>" alt="<?= $product['title']; ?>" class="img-thumbnail"/>
<p class="list-price text-danger">List Price: <s>$<?= $product['list_price']; ?></s></p>
<p class="price">Our Price: $<?= $product['price']; ?></p>
<button type="button" class="btn btn-sm btn-success" onclick = "detailsmodal(<?= $product['id']; ?>)">
Details
</button>
</div>
<?php endwhile; ?>
</div>
</div>
<?php
include 'includes/rightbar.php';
include 'includes/footer.php';
?>
detailsmodal.php:
<?php
require_once 'Core/init.php';
$id = $_POST['id'];
$id = (int)$id;
$sql = "SELECT * FROM products WHERE id= $id";
$result = $db->query ($sql);
$product = mysqli_fetch_assoc($result);
$brand_id = $product['brand'];
$sql1 = "SELECT brand FROM brand WHERE id = '$brand_id'";
$brand_query = $db->query($sql1);
$brand = mysqli_fetch_assoc($brand_query);
$sizestring = $product['sizes'];
$size_array = explode(',', $sizestring);
?>
<!-- Details light box -->
<?php ob_start(); ?>
<div class="modal fade details-1" id="details-modal" tabindex="-1" role="dialog" aria-lebelledby="details-1" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button class="close" type="button" onclick="closeModal()" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title text-center"><?= $product['title']; ?></h4>
</div>
<div class="modal-body">
<div class="container-fluid">
<div class="row">
<div class="col-sm-6">
<div class="center-block">
<img src="<?= $product['images']; ?>" alt="<?= $product['title']; ?>" class="details img-responsive" />
</div>
</div>
<div class="col-sm-6">
<h4>Details</h4>
<p><?= $product['description']; ?></p>
<hr />
<p>Price: $39.99</p>
<p>Brand: <?= $brand['brand']; ?></p>
<form action="Add_cart.php" method="post">
<div class="form-group">
<div class="col-xs-3">
<label for="quantity">Quantity:</label>
<input type="text" class="form-control" id="quantity" name="quantity" />
</div>
</div><br /> <br />
<div class="form-group">
<label for="size">Size: </label>
<select name="size" id="size" class="form-control">
<option value="Select">Select</option>
<?php foreach ($size_array as $string) {
$string_array = explode(':', $string);
$size = $string_array[0];
$quantity = $string_array[1];
echo "<option value='.$size.'>'.$size.' ('.$quantity.' Available)</option>";
} ?>
</select>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-default" onclick="closeModal()">Close</button>
<button class="btn btn-warning" type="submit"><span class="glyphicon glyphicon-shopping-cart"></span> Add To Cart</button>
</div>
</div>
</div>
</div>
<script>
function closeModal(){
jQuery(#details-modal).modal('hide');
setTimeout (function(){
jQuery(#details-modal).remove();
jQuery(.modal-backdrop).remove();
},500)
}
</script>
<?php echo ob_get_clean(); ?>
and here's php function where it is defined in
footer.php:
<script>
function detailsmodal (id) {
var data {"id" : id};
jQuery.ajax({
url : '/Online Store/Includes/detailsmodal.php',
method : "post",
data : data,
success : function(data){
jQuery('body').append(data);
jQuery('#detail-1').modal('toggle')
},
error : function(){
alert("Something went worng...");
}
});
}
</script>
please hurry deadline is coming close.
Thank you in advance.