• Register
2 votes
13 views

Problem :

I am very new to PHP. I am trying to retrieve the image name and then explode and finally to display it. But my problem is I am getting extra blank image in my output. I am struggling to remove the extra blank image from the output.

My Php code as below:

<?php
$imgsql=mysql_query("Select * from mymultiimg WHERE id=100");

$myresult=mysql_fetch_array($imgsql);

$mytemp = explode(',',$result['image'] );

foreach($mytemp as $myimage){
    $myimages[]="photo/".trim( str_replace( array('[',']') ,"" ,$myimage ) );

}
foreach($myimages as $myimage){
  echo "<img src='{$myimage}' height='200' width='300' />";
}
?>

Kindly guide me in fixing the issue.

8 5 2
3,230 points

1 Answer

0 votes

Solution:

I was going through the questions. I found your question more relevant to my skillset so I am trying to help you in fixing your issues in Php programming.

Please don’t worry you will get the desired output from the below code which I have written for you. If you still see the blank image then you need to cross check if those images are already present in your folder.

<?php
$imgsql=mysql_query("Select * from mymultiimg WHERE id=100");
$myresult=mysql_fetch_array($imgsql);
$myimages=$myresult['image'];
$myremove_last_comma=substr($myimages,0,-1);
$mytemp = explode(',',$myremove_last_comma);
for($i=0;$i<count($mytemp);$i++)
{
	echo '<img src="photo/'.trim($mytemp[$i]).'" height="60" width="60">';
	echo "<br />";
    echo "<br />";  
}
?>
Above code will help you in fixing your issues.
8 4
5,680 points

Related questions

0 votes
1 answer 12 views
0 votes
1 answer 7 views
0 votes
1 answer 15 views
0 votes
1 answer 12 views
0 votes
1 answer 10 views
10 views
I want to retrieve an image from the database and display it in my website using the PHP language. But I noticed that it display the name of the file rather than the actual image. At the same time, instead of only one name, there are two photos. I pasted my PHP code below: ... ".$value; } } } Also I want to format the photo to the right corner of my screen. Can you please show me how? Thank you!
asked 6 days ago azriel 340 points