简体   繁体   English

如何从mysql PHP显示图像

[英]How to I display image from mysql PHP

Please help. 请帮忙。 Im trying to display the image of each user using their student ID BUT it displays unknown characters as image on my page as below 我试图使用他们的学生ID显示每个用户的图像但它在我的页面上显示未知字符作为图像,如下所示

% S$P H ~Q - }Y>ZTW ?) ,G ? %S $ PH〜Q-} Y> ZTW?),G? g ~) 1WN { , ! ^j- 9 4 K G〜)1WN {,^!J-94K

$sql_up="SELECT content FROM sp_uploads WHERE s_id= 'RC49557'";
$result_set=mysql_query($sql_up);

while($row_up = mysql_fetch_array($result_set))
 {
    $pp = $row_up['content'];
 } 

    echo "<td>  
 <img style=\"float:right; margin:5px; width:150px; height:150px; padding:10px; \" 
 src=\"  data:image/jpg;charset=utf8;base64,<?php echo $pp ?>   \"  /> </td>"; 

This will do. 这样做。 You don't need to open PHP tags inside PHP tags. 您不需要在PHP标记内打开PHP标记。

$sql_up="SELECT content FROM sp_uploads WHERE s_id= 'RC49557'";
$result_set=mysql_query($sql_up);

while($row_up = mysql_fetch_array($result_set))
 {
    $pp = $row_up['content'];
 } 

 echo "<td>  
 <img style='float:right; margin:5px; width:150px; height:150px; padding:10px;' 
 src='data:image/jpg;charset=utf8;base64, $pp' /> </td>"; 

I'm assuming the img data is correct. 我假设img数据是正确的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM