473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to display image in a row from database ?

10
Hello Everyone....

I want to retrieve the image from the database and want to display it in a row like if there is 20 images in a database then it should get display in 5 rows containing 4 images in each row...
My code is working properly but i am facing problem in image path as i hv stored the image-name in database and image inside admin/uploads folder.... like uploads folder is inside the admin folder... adminfolder/uploadsfolder/file-name

here in my code i am getting problem in tracing the image path.....

Expand|Select|Wrap|Line Numbers
  1. echo "<td><img src=\"".$path[$i]."\" height='100'/></td>";
Here is my Full Code

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. mysql_connect('localhost','root','') or die(mysql_error());
  3. mysql_select_db('dogs_db') or die(mysql_error());
  4.  
  5. $sql = "SELECT file_name FROM dogsinfo";
  6. $res = mysql_query($sql) or die(mysql_error());
  7. echo "<table><tr>";
  8. while($fetch = mysql_fetch_assoc($res)) {
  9. $path[] = $fetch['file_name'];
  10. }
  11.  
  12. for($i=0;$i<count($path);$i++){
  13.  
  14. if($i%4 == 0){
  15. echo "</tr>";
  16. }
  17. // I am Facing Problem here ... 
  18. // my all images is in admin/uploads folder
  19.  
  20. echo "<td><img src=\"".$path[$i]."\" height='100'/></td>";
  21.  
  22. }
  23. echo "</tr></table>";
  24. ?>
  25.  

Please help me to sort out this.... I am new to php
May 3 '14 #1
4 3006
Luuk
1,047 Expert 1GB
Have you tried:
Expand|Select|Wrap|Line Numbers
  1. echo "<td><img src='admin/uploads/".$path[$i]."' height='100'.....
  2.  
May 3 '14 #2
pavan52
10
ya i hv tried it but dnt know why its not working....
May 4 '14 #3
Luuk
1,047 Expert 1GB
Look at the log of your web-server, and at the source code produced by your script.

Do they match? If not, than the error log might become useful.
May 4 '14 #4
yeah thanks this is just what I need
May 11 '14 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tan | last post by:
Hi I am desperate for any help with display image in Gridview I have a gridview contain surname , forename ..... and image. I could not display image as my database store the column image as...
3
by: harish | last post by:
Hi friends I am facing problem as follow I can't display image from SQL Database to Picture box Control. Here are the codes that I am writing Dim arrPicture() As Byte = _
2
by: RedSouljaz | last post by:
Hi, How to display image that was saved in database ms sql server 2000 into picture box. The field type that I use in database is Images I can save to database but cannot show from database. ...
3
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
7
by: eholz1 | last post by:
Hello Group, Perhaps you can help me. I have a mysql db, that holds images. Images are encoded using base64_decode/encode, etc. Image data seems fine. I have a view.php page that is supposed...
7
by: alexseow | last post by:
Query.asp <%@ LANGUAGE="VBSCRIPT" %> <!-- #include file="../../includes/dbconn.asp"--> <% dim MyRs, sqlstr, MyConn Response.Expires = 0 Response.Buffer = TRUE Response.Clear
1
by: shalini328 | last post by:
I am using ASP.net 1.1 C# and database is MS access.Can you tell me how can i display image from database
1
by: saadkhan | last post by:
I want to display image in <img> tag using database. I just need to know that how could i be able to define path or whatever to <img> tag. I have no probem in making queries to database.....plz help
5
by: SafaaDalloul | last post by:
Please I want know How I can Display Image from database randomly when the web page refresh in Asp.net by C# code
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.