I'm fetching images from database. I wrote the php script given below, only the "echo" statement in while loop is working but the variables not showing values coming from database.In other words, only html is working.
There is no any error as such. I don't know wht's the issue.
Help me. Thanks !
$db_username = 'xxxxx';
$db_password = 'xxxx';
$db_name = 'xxxx';
$db_host = 'localhost';
$item_per_page = 9;
$mysqli = new mysqli($db_host, $db_username, $db_password, $db_name);
if ($mysqli->connect_error) {
die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}
$page_number = filter_var($_POST["page"], FILTER_SANITIZE_NUMBER_INT, FILTER_FLAG_STRIP_HIGH);
if(!is_numeric($page_number)){
header('HTTP/1.1 500 Invalid page number!');
exit();
}
$position = (($page_number-1) * $item_per_page);
$results = $mysqli->prepare("select * FROM inserting_discount_product ORDER BY id DESC LIMIT ?, ?");
$results->bind_param("dd", $position, $item_per_page);
$results->execute(); //Execute prepared Query
$results->bind_result($pro_id, $pro_title,
$pro_cat,$pro_desc,$pro_price,$pro_img,$pro_discount_price,$pro_discount_percent
age,$product_code);
while($results->fetch()){
echo "
<div id='$pro_id' class='col-md-3 col-sm-4 col-xs-12'>
<h3 style='color:black'; align='center'>$pro_title</h3>
<div>
<img src='../admin_area/product_images/product_pics/$pro_img' width='180' height='180' /> <br>
</div>
<p style='color:black;margin-right:12px'><b>Price: $ $pro_discount_price </b>
<span style='color:black;text-decoration:line-through;margin-left:15px'>
<b style='color:red'>Price: $ $pro_price</b>
</span>
</p>
<a href='details.php?pro_id=$pro_id' style='margin-right:10px' class='detail_hover'><b>Details</b></a>
<span style='font-weight:bolder'>$pro_discount_percentage %</span>
<a href='index.php?add_cart=$pro_id&product_code=$product_code' style='color:orange;margin-left:10px' class='basket-logo'>
<span class='fa fa-shopping-cart fa-2x'></span></a>
</div>
";
}