• Register
2 votes
20 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

Please log in or register to answer this question.

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 28 views
0 votes
1 answer 22 views
0 votes
1 answer 15 views
15 views
The small project that I have is a relational database. It requires me to fetch the information from mysql database. I have two requirements, 1) get the information from the database and fill up the "<select>" option tag with the id and its name. 2) When I select the list of names, then the ... > <td>Salazar</td> <td>437-425-xxxx</td> <td>A560-123</td> <td>$5,000</td> </tr> </tbody> </table>
asked Oct 29, 2020 RJ Lam 650 points
0 votes
1 answer 38 views
0 votes
1 answer 18 views
0 votes
1 answer 23 views
23 views
Problem: I have two tables, one master and the other the details. What I need to retrieve the data from the master and then, in every master the details also. So I don't know how to put them into a variable for me to process later. Here is my diagram: Items: 1 - Boxes - ... - Blue 2 - Crayons - 8 Colors - 16 Colors - 24 Colors Anyone who can show me with an example or demo on how to do it? Thanks
asked Nov 9, 2020 Reina Joy 360 points
0 votes
1 answer 13 views
13 views
Hi, I have a small php project. I need a php class that will enable me to retrieve the information from a database so that I can display in a table as shown in this html code: <!DOCTYPE html> <html> <head> <title>List of Cars</title> </head> <body> <table> <tr> <th>Year</th> <th>Brand</ ... >AUDI Q2 2020</td> </tr> <tr> <td>2020</td> <td>Volvo</td> <td>Xc60 2020</td> </tr> </table> </body> </html>
asked Oct 11, 2020 azriel 590 points
0 votes
1 answer 17 views
17 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 Oct 13, 2020 azriel 590 points
0 votes
1 answer 8 views
0 votes
1 answer 19 views