Php 无法显示逗号分隔字符串中的图像
我正在尝试显示数据库中的图像,但无法显示。 请帮帮我 我的代码Php 无法显示逗号分隔字符串中的图像,php,Php,我正在尝试显示数据库中的图像,但无法显示。 请帮帮我 我的代码 $id = $_GET['reg_id']; $sql13 = "select * from contacts where reg_id=" . $id; $result13 = mysqli_query($conn, $sql13); if (mysqli_num_rows($result13) > 0) {
$id = $_GET['reg_id'];
$sql13 = "select * from contacts where reg_id=" . $id;
$result13 = mysqli_query($conn, $sql13);
if (mysqli_num_rows($result13) > 0) {
while($documents = mysqli_fetch_array($result13))
{ ?>
<li class="make_text1" style="font-size:16px">
<span class="definition"><b>
<?php if(!empty($documents["name"])){ echo
$documents["name"]; }?><br><?php
if(!empty($documents["image"])){
$upload_dir = 'uploads/';
// echo "<img src='uploads/".$documents["image"]."' width='800' height='500'> ";
echo "<img src='uploads/".$documents["reg_id"]."/".$documents["image"]."' width='800' height='500'> ";
}
$id=$\u GET['reg\u id'];
$sql13=“从reg_id=”的联系人中选择*$身份证件
$result13=mysqli_查询($conn,$sql13);
如果(mysqli_num_rows($result13)>0{
而($documents=mysqli\u fetch\u数组($result13))
{ ?>
您需要循环使用$documents[“image”]
中的值。请尝试以下操作:
$images = explode(',', $documents["image"]);
foreach ($images as $image) {
echo "<img src='uploads/".$documents["reg_id"]."/$image' width='800' height='500'> ";
}
$images=explode(“,”,$documents[“image]”);
foreach($images作为$image){
回声“;
}
或者,如果您只想显示其中一个,例如第一个,则如下所示:
$images = explode(',', $documents["image"]);
echo "<img src='uploads/".$documents["reg_id"]."/".$images[0]."' width='800' height='500'> ";
$images=explode(“,”,$documents[“image]”);
回声“;
您需要循环使用$documents[“image”]
中的值。请尝试以下操作:
$images = explode(',', $documents["image"]);
foreach ($images as $image) {
echo "<img src='uploads/".$documents["reg_id"]."/$image' width='800' height='500'> ";
}
$images=explode(“,”,$documents[“image]”);
foreach($images作为$image){
回声“;
}
或者,如果您只想显示其中一个,例如第一个,则如下所示:
$images = explode(',', $documents["image"]);
echo "<img src='uploads/".$documents["reg_id"]."/".$images[0]."' width='800' height='500'> ";
$images=explode(“,”,$documents[“image]”);
回声“;
文件名用逗号分隔是否正确?您需要引用“image”属性,而不是“reg\u Id”是的,因为每个文档类型id都有多个图像。我想为每个文档类型id上载多个图像。@Carl Binalla当我删除注册表id时,它仍然不起作用@Russ JYou确实知道每次使用$documents[“image”]
它为您提供了存储的确切值,即带逗号的文件名?在
中使用文件名之前,您仍然需要将文件名分隔开。我是否正确地看到文件名由逗号分隔?您需要引用“image”属性,而不是“reg\u Id”是的,因为每个文档类型id都有多个图像。我想为每个文档类型id上载多个图像。@Carl Binalla当我删除注册表id时,它仍然不起作用@Russ JYou确实知道每次使用$documents[“image”]
它给出了它存储的确切值,即带逗号的文件名?在
@Prabina中使用文件名之前,您仍然需要将文件名分隔开。代码缺少对explode
的调用,无法在文件名以逗号分隔时对其进行分隔。我现在已经添加了这一点。@Prabina代码缺少对的调用分解
以在文件名以逗号分隔时将其分隔。我现在已经添加了这个选项。