hi i am trying to Retrieve an image with details on another page. using the id but noting displays and i get the id when i var_dump(); the getRows(); returns null i am stock here would need help. here is my code. thanks.
if (!isset($_GET['pro_id'])){
}
else{
$pro_id=$_GET['pro_id'];
//select from the db
$query= "SELECT * FROM `property` where pro_id=:pro_id limit 1";
$params=[':pro_id'=>$pro_id];
var_dump($params);
$property=$db->getRows($query,$params);
var_dump($property);
if (!$property){
$result[]='Empty array';
}else{
$property=[0];
$propertyname=$property['property_name'];
$property_location=$property['property_location'];
$propertyprice=$property['property_price'];
$category_id=$property['category_id'];
$status=$property['status'];
$query= "SELECT * FROM `property_img` where pro_id=:pro_id limit 1";
$params=[':pro_id'=>$id];
$property_img=$db->getRows($query,$params);
var_dump($property_img);
$property_img=[0];
$property_img=$property_img['property_img'];
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Property</title>
</head>
<body>
<?php
if (isset($result)){
implode( " " , $result);
exit;
}
?>
<div class="container">
<!-- Full-width images with number text -->
<div class="row">
<div class="property_name col-md-8 col-sm-6 col-lg-8">
<h1><?php echo $propertyname; ?></h1> <div class='image'>
<div class="mySlides">
<div class="numbertext">1 / 6</div>
<?php
foreach ($property_img as $property_img) {
$pro_id = $property_img['pro_id'];
$property_img = $property_img['property_img'];
?>
<tr>
<td>
<img src="<?php echo 'UploadFolder/'.$property_img; ?>" alt="" />
</td>
</tr>
<?php
}
?>
<div class="description">
<?php echo $property_location;?>
</div>
</div>
<div class="column">
<ul><li>
<img class="demo cursor" src="<?php
echo $property_img;
//echo $img ?>" style="width:100%" onclick="currentSlide(1)" alt="" /></li></ul>
</div>
</div>
</div>
<div class=" col-md-3 ">
<hr><h2>Agent</h2>
<img src="image/gmplogo.jpg" width="150px" height="120px"><br>
<!--soial media links---->
<div class="social-links">
<ul class="social-icon-four">
<li><a href="#"><span class="fa fa-facebook"></span></a></li>
<li><a href="#"><span class="fa fa-twitter"></span></a></li>
<li><a href="#"><span class="fa fa-whatsapp"></span></a></li>
</ul>
</div>
<button><a href="" class="btn_info">Contact agent</a></button>
<button><a href=""class="btn_info">Agent information</a></button>
<hr><h2> Description</h2>
<p> <?php echo $property_location;?> </p>
<hr><h2> Property Details</h2>
<p> Property: <?php echo$propertyname;?></p>
<p>Property Location: <?php echo $property_location;?></p>
<p>Property Price: <?php echo $propertyprice;?></p>
<p> Agent: MR Felix </p>
</div>
</div>
<div class="row">
<div class=" col-md-3"> <hr><h2>Agent</h2>
<img src="image/gmplogo.jpg" width="150px" height="120px"><br>
<!--soial media links---->
<div class="social-links">
<ul class="social-icon-four">
<li><a href="#"><span class="fa fa-facebook"></span></a></li>
<li><a href="#"><span class="fa fa-twitter"></span></a></li>
<li><a href="#"><span class="fa fa-whatsapp"></span></a></li>
</ul>
</div>
<button><a href="" class="btn-info">Contact agent</a></button><br>
<button><a href=""class="btn-info">Agent information</a></button><br>
</div>
<div class="col-md-6">
<hr><h2> Description</h2>
<p> <?php echo $property['property_location'];?> </p>
</div>
<div class=" col-md-3">
<hr><h2> Property Details</h2>
<p> Property: <?php echo $property['property_name'];?></p>
<p>Property Location: <?php echo $property['property_location'];?></p>
<p>Property Price: <?php echo $property['property_price'];?></p>
<p> Agent: MR Felix </p>
here is my function.
public function getRows($query,$params=[]){
try{
$stmt=$this->datab->prepare($query);
$y=$stmt->execute($params);
$x=$stmt->fetchAll();
return $x;
echo $x;
echo $y;
}
catch (PDOException $e){
throw new Exception($e->getMessage());
}
}