473,405 Members | 2,154 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,405 software developers and data experts.

Display img sec using PHP

I have a database where I store images, or rather paths to images.
I can display the images using http://www.domain.com/show.php?img=1.jpg&mid=1

Using that page it shows 4 images in a table 2 side by side and 2 side by side on the next row.

I want to call the show.php page from another file using the <img src>. Is it even possible?
Sep 15 '10 #1
4 1716
TheServant
1,168 Expert 1GB
So I think that you're wanting to dynamically create an image of a page to show in another page using an <img /> tag?

This is possible using PHP GD Library, although I have never tried. I don't have much time at the moment to research this, but I have given you a few key words to google with. Also read a bit of what the GD Library can do here.
Sep 15 '10 #2
Canabeez
126 100+
There's no need to use the GD library if you don't want to combine images. You can dynamically draw them on the page using either PHP of JS.

If you want to use PHP to output and image, then just:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     ob_start();
  3.     $imageId = isset($_GET['img']) ? addslashes($_GET['img']) : false;
  4.  
  5.     if(!$imageId){
  6.         exit;
  7.     }
  8.  
  9.     $result = mysql_query("
  10.         SELECT `image` FROM `images` WHERE `image_id` = {$imageId} LIMIT 1
  11.     ");
  12.  
  13.     $imageObject = mysql_fetch_object($result);
  14.     $image = $imageObject->image;
  15.  
  16.     header("Content-Type: " . mime_content_type($image) . ";\n");
  17.  
  18.     echo file_get_contents($image);
  19.     ob_end_flush();
  20.     exit;
  21. ?>
Sep 15 '10 #3
Markus
6,050 Expert 4TB
Canabeez, the output-buffering is redundant there, as you are not outputting anything before the call to header().

Mark (the Pedantic).
Sep 15 '10 #4
Canabeez
126 100+
Thank's Mark, you completely right.
Sep 15 '10 #5

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

Similar topics

0
by: Don | last post by:
I have a client page that employs hover buttons. They work just fine in IE. But, when using Netscape, they intermittently won't display. When they don't display, all that shows is a gray box the...
3
by: Paul | last post by:
I have some option boxes and combo boxes that looks up values on a separate table (i.e. campus table with campusID & campus name fields) When I choose a selection from the combo box, it puts the...
2
by: Rahul | last post by:
Hey Guys I have a development environment, in which the whole SQL syntax is stored in the Database. So the syntax in the databse column could be "where BirthDate = '12/31/2005' and ID =...
3
by: rajarya | last post by:
Hi, I m designing a HTML page(index.html),here i have 2 frames,by defult both frames have index1.html and index2.html as their source . in first frame(index.html) ,i have some redio buttons,and a...
1
by: pankhudi | last post by:
Hi,i am doing a graphics project (in C),wherein i need to display text.Obviously could have directly used outtextxy or other such functions but the problem is that i dont have to use stdandard...
2
by: Pradeep | last post by:
When using CSS to display an XML file as a table, is there a way to show the element names at the tops of the columns as headers? For Example : I have a XML file <ITEMLIST> <ITEM> <NAMEItem1 ...
1
by: raj | last post by:
Hi, can anyone help me in fetching the xml value from the table of column datatype xml,and i need to display the same using xslt and java. Thanks in Advance Raj
1
by: vineetbindal | last post by:
Hi all, I have a datagrid and detailsview. when a user selects a row in datagrid onSelectedIndexchanged is fired and Detailsview comes into picture. I want to display the data of the selected row...
3
by: btreddy | last post by:
Hiii experts , I've received one critical requirement from my customer this morning. I've a gridview,in one of my webpage, which displays all the prticipants who are participating in a...
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
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
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
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
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...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.