473,395 Members | 1,412 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,395 software developers and data experts.

Image Display Issue

I am a noobie.. so bare with me. This has got to be easy..but i can;t figure it out.

I am trying to display and image based on a photo name in a mysql database.

That would be easy enough except I need to get that name from a recordset because this is a detail page from a master set and it dynamic.

This is the code i was trying that doesn't work..

<img src="http://bytes.com/topic/php/idphoto/<?php echo $row_DetailRS1.photo ?>" width="157" height="232" align="top" />

The whole photo names are stored in the database (example photo.jpg)
May 29 '09 #1
7 1272
prabirchoudhury
162 100+
hey .. a quick question .. what name you store the image in database? is that with extension (.jpg , .gif) ? are all the images saved in same directory or different in server ?
May 29 '09 #2
@prabirchoudhury
I rename the images upon upload to their unique username. As far a extension.. eithrer jpg, png or gif.. They are all in the same folder on the server.
May 29 '09 #3
prabirchoudhury
162 100+
ok..

here your image tag should be

Expand|Select|Wrap|Line Numbers
  1. <img src="image_directory/<?php echo $row['imagename']; ?>" width="157" height="232" align="top" />
  2.  
that should work if you supply all right information abt immage

:)
May 29 '09 #4
@prabirchoudhury
But i need to pull the image name from the data base?
May 30 '09 #5
prabirchoudhury
162 100+
ok...


1. you need to connect with database using php
Expand|Select|Wrap|Line Numbers
  1.  <?php
  2.  $mysqlconnec= mysql_pconnect($your_hostname, $db_username, $db_password) or die((mysql_error());
  3.     $db = mysql_select_db($your_database, $mysqlconnec);
  4.  
  5.  ?>
  6.  
  7.  

2. make a select statement of your table where you could get the images name
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $sql = "SELECT * from your table_name ";
  4. //execute the query
  5.  $csr = mysql_query($sql);
  6. // retrieve the image details frm table
  7. while ($row=mysql_fetch_array($csr)) {
  8.  
  9.  
  10. $your_image_name = $row['imagename'];
  11.  
  12. }
  13.  
  14. ?>
  15.  
  16.  

3. now you got your image details so could add this in html
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. :)
  4.  
  5.  
  6.    1. <img src="image_directory/<?php echo $your_image_name; ?>" width="157" height="232" align="top" />
  7.    2.  
  8.  
  9.  
  10.  

you need to read the basic php /mysql tutorials
May 30 '09 #6
Markus
6,050 Expert 4TB
It depends what database you're using. Google '<database type> php tutorial'.
May 30 '09 #7
Thanks so much!!! it worked..
May 30 '09 #8

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

Similar topics

6
by: Ken | last post by:
How does IE6 control the display of images? I change the content of a image file image1.jpg without changing the file name. Then jump to a new page to display it. IE6 does not displays the...
1
by: Tim Burda | last post by:
I am having some problems with getting an .gif file to display properly on an ASPX page. The image appears grainy and distorted. I have tried implementing the image (stored in several formats)...
4
by: Angel | last post by:
Is there anyway that I can obtain information about an image file such as a ..jpg before I display it onto a screen. In other words, I would like to obtain the image size so I can dynamically place...
2
by: David | last post by:
I am trying to get an image to appear on all Mondays within the calendar control. I also want that image to be a link. How can I do this?
2
by: Abhishek Srivastava | last post by:
Hello All, I am trying to obtain an image asynchronously for this I have written code which uses XMLHTTP object to retreive the image. now I have to display this image in an iframe. when I say...
4
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. ...
1
by: ApexData | last post by:
Hello I am in the early stages of my project development, and want to make sure that I am approaching the issue of image display correctly. Access2000. I have one table and a bound single...
1
by: shotokan99 | last post by:
i have this issue: showpic.php ================================================ $ch = curl_init(); $timeout = 0; curl_setopt ($ch, CURLOPT_URL, $xmyurl); curl_setopt ($ch,...
0
by: punitshrivastava | last post by:
Hi to All, I am Punit Shrivastava.i created one html page for this i cde like this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
2
by: jerrygadd | last post by:
Can some body help me vertically center an image using CSS? The customer only uses IE, and so the code is not debugged for other browsers! The image in question is found on line 1075 :...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.