473,472 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Image in a Table

34 New Member
CAn someone help me to put an image inside a <table> in php. i have used echo '<table>' function but i did not work form me. it out put some hex codes.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. echo '<table>';
  4. <tr>
  5. <td>
  6. $file='cow.jpg';
  7. $src_img = imagecreatefromjpeg($file); 
  8. $srcsize = getimagesize($file);
  9.  
  10. $dest_x = 250; 
  11. $dest_y = (250 / $srcsize[0]) * $srcsize[1]; 
  12. $dst_img = imagecreatetruecolor($dest_x, $dest_y);
  13.  
  14. imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, 
  15. $dest_x, $dest_y, $srcsize[0], $srcsize[1]); 
  16.  
  17. header("content-type: image/jpeg");
  18.  
  19. imagejpeg($dst_img);
  20. </td>
  21. </tr>
  22. echo '</table>';
  23. ?>
  24.  
thanks
Apr 7 '08 #1
7 1611
TheServant
1,168 Recognized Expert Top Contributor
At the beginning, you have echo '<table>'; but then you have <tr>??? All you code is in php, so you need to echo any html like so:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. echo '<table><tr><td>';
  3. $file='cow.jpg';
  4. $src_img = imagecreatefromjpeg($file); 
  5. $srcsize = getimagesize($file);
  6.  
  7. $dest_x = 250; 
  8. $dest_y = (250 / $srcsize[0]) * $srcsize[1]; 
  9. $dst_img = imagecreatetruecolor($dest_x, $dest_y);
  10.  
  11. imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_x, $dest_y, $srcsize[0], $srcsize[1]); 
  12.  
  13. header("content-type: image/jpeg");
  14.  
  15. imagejpeg($dst_img);
  16.  
  17. echo '</td></tr></table>';
  18. ?>
  19.  
I am not familiar with the imaging function you have used, so I will leave that for someone else to comment on, however I am pretty sure your header line will not work as this needs to be done at the top of the page. I could be wrong, but I always have trouble with that. Fix up your php echo-ing and then also post what the output is so maybe we can have a better idea.
Apr 7 '08 #2
infoseekar
34 New Member
At the beginning, you have echo '<table>'; but then you have <tr>??? All you code is in php, so you need to echo any html like so:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. echo '<table><tr><td>';
  3. $file='cow.jpg';
  4. $src_img = imagecreatefromjpeg($file); 
  5. $srcsize = getimagesize($file);
  6.  
  7. $dest_x = 250; 
  8. $dest_y = (250 / $srcsize[0]) * $srcsize[1]; 
  9. $dst_img = imagecreatetruecolor($dest_x, $dest_y);
  10.  
  11. imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_x, $dest_y, $srcsize[0], $srcsize[1]); 
  12.  
  13. header("content-type: image/jpeg");
  14.  
  15. imagejpeg($dst_img);
  16.  
  17. echo '</td></tr></table>';
  18. ?>
  19.  
I am not familiar with the imaging function you have used, so I will leave that for someone else to comment on, however I am pretty sure your header line will not work as this needs to be done at the top of the page. I could be wrong, but I always have trouble with that. Fix up your php echo-ing and then also post what the output is so maybe we can have a better idea.
Thanks TheServant . Its working not but instead of the picture some hex codes are displaying inside the table.

thanks
Apr 7 '08 #3
TheServant
1,168 Recognized Expert Top Contributor
I'm presuming you mean "it's working now"? Anyway, please post what is appearing in the table... I have an inkling about what it is, but I need to see the output first.
Apr 7 '08 #4
Atli
5,058 Recognized Expert Expert
Hi.

The problem here is that you are printing the image data as HTML.
As a result, the image is being displayed as if it were a string of letters.

What you need to do is use the <img> tag and link to the image you want displayed.

If you are trying to modify an existing image using PHP code, and you want that image in your table, you will simply have to put that code into a separate PHP file and link to that in your <img> tag.
Apr 7 '08 #5
infoseekar
34 New Member
Hi.

The problem here is that you are printing the image data as HTML.
As a result, the image is being displayed as if it were a string of letters.

What you need to do is use the <img> tag and link to the image you want displayed.

If you are trying to modify an existing image using PHP code, and you want that image in your table, you will simply have to put that code into a separate PHP file and link to that in your <img> tag.
Thanks for your help.

I have a php code to get an image then size the the image and display it. what i want to do is to display that image inside a table.

I will try what u recommended..
Apr 8 '08 #6
infoseekar
34 New Member
I'm presuming you mean "it's working now"? Anyway, please post what is appearing in the table... I have an inkling about what it is, but I need to see the output first.

The output was some hex codes inside the table.

thanks
Apr 8 '08 #7
TheServant
1,168 Recognized Expert Top Contributor
The output was some hex codes inside the table.

thanks
Never mind, Alti suggested basically what I was going to suggest. Tell us how that goes.
Apr 8 '08 #8

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

Similar topics

7
by: Andrew Poulos | last post by:
I'm using the following code to create a small table with one column and two rows. An image goes into the first cell. //create table var t = document.createElement("TABLE"); t.style.position =...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
6
by: nichughes | last post by:
Hello all, A question relating to http://www.entrust-systems.net/ Just for a change I have run into a problem that seems to be OS specific rather than browser specific - the box image that is...
0
by: wizardworkz | last post by:
Hello All! Having a bit of a problem combining php with javascript here. What I have is a store with images (There will be a smaller image of each item, and a larger image of each item, but I want...
2
by: Poppa Pimp | last post by:
ImageResizer.php Image Resizer PLEASE HELP The URL of the page this is on in my site is http://poppa-pimps-wallpapers.com//ImageResizer.php You can click on browse and get image,but...
5
by: tshad | last post by:
I have a table with an image in it that is larger that the width and height. <table class="dataTable" width="500px" height="400px" border="0" cellpadding="0" cellspacing="0"> <tr height="400px"...
11
by: Chris Beall | last post by:
See http://pages.prodigy.net/chris_beall/Demo/photo%20block%20experiments.html I've ended up with what seems like a rather complex structure for what I thought would be a somewhat simple...
1
by: rsteph | last post by:
I've got some product information pages, with images and text, all setup within a table. I'm trying to add a small image in the upper right hand corner of the content div (where all the important...
4
by: yatin | last post by:
hi, friend. i have a problem in image validation plz check it. i have to include a image validation in foam 1. but i sending a details through form2. But when i include a image validation in foam1,...
3
by: premprakashbhati | last post by:
hi, good evening.. i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button() here is the code ...its work fine...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.