select rate, comment, date_format(c.lupdate, '%b %e, %Y') as dateformated, if(imgurl like '%youtube.com%', concat('_iframe width=560 height=315 src="', replace(imgurl, "watch\?v=", "embed/" ), '" frameborder=0 allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>'), concat('')) as img from comments c where c.jid=8537;
it works for images as well. php code
$media="if(imgurl like '%youtube.com%', concat('_iframe width=560 height=315 src=\"', replace(imgurl, \"watch\?v=\", \"embed/\" ), '\" frameborder=0 allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen>'), concat('')) as img";
$sql2="select rate, comment, date_format(c.lupdate, '%b %e, %Y') as dateformated,
concat(' by ', u.name,' ') as msg, $media
from comments c inner join users u on (u.id=c.uid) where c.jid=$jid;";