mysql - Make SQL column using PHP explode into variable -
mysql - Make SQL column using PHP explode into variable -
hey guys i'm having bit of problem trying create sql column variable in php.
so sql row contains image url's , formatted this:
http://www.website.com/image.jpg,http://www.website.com/image2.jpg,http://www.website.com/image3.jpg
so need display first url in row.
i have short line of code:
file = '.(explode(',', $cardata["picturerefs"])[0]).';
i trying give variable value of:
$file = "http://www.website.com/image.jpg"
my current code wrong sense must quite close. how can accomplish this?
your short hand correct, string encapsulation not required.
$file = explode(',', $cardata['picturerefs'])[0]; // first image src
then can utilize like:
echo '<img src="'.$file.'"/>';
php mysql
Comments
Post a Comment