How to fetch all the image names from other table PHP - MySQL -
mates have problem using other table data. please @ code:
$sql = mysqli_query($con, "select * properties category '$property_for' , property_type '$property_type' , search_radius >= '$area' , price >= '$price_min' , price <= '$price_max' , bed_rooms '$beds' , bath_rooms '$baths' order date_added desc") or die(mysqli_error($con)); $productcount = mysqli_num_rows($sql); if ($productcount > 0) { while($row = mysqli_fetch_array($sql)) { $pid = $row["property_id"]; $agent_id = $row["agent_id"]; $property_name = $row["property_name"]; $category = $row["category"]; $location = $row["location"]; $property_type=$row["property_type"]; $price = $row["price"]; $bed_rooms = $row["bed_rooms"]; $bath_rooms = $row["bath_rooms"]; $commercial_type = $row["commercial_type"]; $area = $row["area"]; $address = $row["address"]; $description = $row["description"]; $date_added = $row["date_added"]; $date_added = strftime("%b %d, %y", strtotime($row["date_added"])); $imagesql = mysqli_query("select * tbl_images pid = '$pid'"); while($row = mysqli_fetch_array($imagesql)) { $image = row['image_name']; // here there totally 3 image_names. want fetch image names } } }
here using 2 table named properties
, tbl_images
. in properties
inserted data category, price, size that. single values. in tbl_images
, inserted 3 image_names
reference of properties
table's product_id
. so, need fetch data in properties
table , 3 image_names
in tbl_images
table reference of property_id
in properties
table. problem. so, mates me... think array script. don't know , how this. please me.
$imagesql = mysqli_query("select * tbl_images pid = '$pid'"); $images = array(); while($i = mysqli_fetch_array($imagesql)) { $images[] = $i['image_name']; } var_dump($images); //will contain array of images
Comments
Post a Comment