How to insert multiple image names in a same row and display it php-mysql -
i struggling on mysql me. using
$sql = "insert properties (agent_id, property_name, category, location, property_type, search_radius, price, bed_rooms, bath_rooms, commercial_type, area, address, description, image_name, date_added) values ('$agent_id', '$property_name', '$listing_for', '$city', '$property_type', '$area', '$price', '$beds', '$baths', '$commercial_type', '$area_sf', '$address', '$description', '".$filename."', now() )" ;
this query insert values database. here image_name
($filename
) contains 3 images. getting names using array , insert db. here fields single. image_name contains 3 values. when use script inside loop, totally 3 rows inserted. when use outside loop inserted last $filename
. need want add 3 image_names
, other data single row. after need fetch data display it. how can that. me mates. thanks.
use code,
foreach ($filename $key => $value) { $array[] = $value; } $arrayvalue = json_encode($array); $sql = "insert properties (agent_id, property_name, category, location, property_type, search_radius, price, bed_rooms, bath_rooms, commercial_type, area, address, description, image_name, date_added) values ('$agent_id', '$property_name', '$listing_for', '$city', '$property_type', '$area', '$price', '$beds', '$baths', '$commercial_type', '$area_sf', '$address', '$description', '".$arrayvalue."', now() )" ;
Comments
Post a Comment