I have been trying to get the description to show up in a bootstrap modal. I can pull the price, quantity, list price, and title from the database but when I try to pull the data for the description it makes my info all disappear. I am trying to figure out why?
I have tried several different things and to no avail I have not been able to figure this issue out. I would love a answer to this issue. It is stopping the progress of my project that needs to be completed soon.
When I add description to the code my info disappears on the first modal button clicked. The 2nd modal button clicked shows all info but then whenI go to the 4th and 5th modal button I get the same info as the 4th modal button. When I take out description from SELECT then all data shows up in modal except for the description. I am at a loss and truly need more understanding of what I might have done wrong. Thank you for your time. The actual site is up http://www.pdnauction.com and right now the description is in the code so that it shows the issues.
$(document).ready(function(){
$(document).on('click', '#getProducts', function(e){
e.preventDefault();
var id = $(this).data('id');
$('#products-detail').hide();
$('#products_data-loader').show();
$.ajax({
url: 'empData.php',
type: 'GET',
data: 'id='+id,
dataType: 'json',
cache: false
})
.done(function(data){
console.log(data.title);
$('#products-detail').hide();
$('#products-detail').show();
$('#id').html(data.id);
$('#products_title').html(data.title);
$('#products_price').html("$"+data.price);
$('#products_list_price').html("$"+data.list_price);
$('#products_image').html(data.image);
$('#products_description').html(data.description);
$('#products_quantity').html(data.quantity);
$('#products_data-loader').hide();
})
.fail(function(){
$('#products-detail').html('Error, Please try again...');
$('#products_data-loader').hide();
});
});
});
<?php
include_once ("core/init.php");
if($_REQUEST['id']) {
$sql = "SELECT id, title, price, list_price, quantity, description FROM products WHERE id='".$_REQUEST['id']."'"; $resultset = mysqli_query($conn, $sql) or die("database error:". mysqli_error($conn));
$data = array();
while( $rows = mysqli_fetch_assoc($resultset) ) {
$data = $rows;
}
echo json_encode($data);
}
?>
<div id="emp-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria- hidden="true"></button>
<h4 class="modal-title">
<i class="glyphicon glyphicon-user"></i> Product Description
</h4>
</div>
<div class="modal-body">
<div id="products_data-loader" style="display: none; text- align: center;">
<img src="ajax-loader.gif">
</div>
<div id="products_data-loader">
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-striped table-bordered">
<tr>
<th>Product</th>
<td id="products_title"></td>
</tr>
<th style="color: green">Price</th>
<td id="products_price" style="color: green"></td>
</tr>
<tr>
<th><s style="color: red">List Price</s></th>
<td id="products_list_price" style="color: #ff0000"></td>
</tr>
<tr>
<th>Quantity</th>
<td id="products_quantity"></td>
</tr>
<tr>
<th>Description</th>
<td id="products_description"></td>
</tr>
<tr>
<th>Gallery</th>
<td id="products_image"></td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>