Getting PHP Data To Load Through IMG SRC Tag?
Moderator: General Moderators
Getting PHP Data To Load Through IMG SRC Tag?
Hey,
Although I've searched a million pages, I struggle getting PHP code (a list of 10 records through a db, in text form)
to display through img src tag. The reason I need to do this is because I am modifying a template based software where
the .tpl file has the section of code that needs to display a dynamic list of 10 records.
Problem is, I cannot get PHP to parse and display the data. When I use .htaccess to try to allow .tpl files to work as php, that fails
And when I type the php code I can see it, intact, through the source code because nothing is happening.
So, if I try to pull this data, such as
img src="path/to/phpfile.php", where phpfile.php is a file that displays the top 10 records, how do I get it to load?
DO I need phpfile.php to have content types listed? When I try to load it through a test html page, I get a fudged up 'image'
Any advice would be appreciated. Thanks
Although I've searched a million pages, I struggle getting PHP code (a list of 10 records through a db, in text form)
to display through img src tag. The reason I need to do this is because I am modifying a template based software where
the .tpl file has the section of code that needs to display a dynamic list of 10 records.
Problem is, I cannot get PHP to parse and display the data. When I use .htaccess to try to allow .tpl files to work as php, that fails
And when I type the php code I can see it, intact, through the source code because nothing is happening.
So, if I try to pull this data, such as
img src="path/to/phpfile.php", where phpfile.php is a file that displays the top 10 records, how do I get it to load?
DO I need phpfile.php to have content types listed? When I try to load it through a test html page, I get a fudged up 'image'
Any advice would be appreciated. Thanks
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Getting PHP Data To Load Through IMG SRC Tag?
What exactly are you trying to display in the image tag?
You need to send the correct content types using header() then send the binary image to be displayed using readfile()
Take a look at some of the examples on the header() documentation, particularly this one
You need to send the correct content types using header() then send the binary image to be displayed using readfile()
Take a look at some of the examples on the header() documentation, particularly this one
Re: Getting PHP Data To Load Through IMG SRC Tag?
Imagine needing a template file (file.tpl) to display a current list of 10 records through Mysql
The file 'viewrecords.php' has the list of them. But what if you need a cross browser solution to display those records, from viewrecords.php,
in the .tpl file?
I figured using img src tag would do that. I was wrong
So, in essence, I need to know how to get the darn .tpl file to display the records. I have a php file that runs this script
which reads the .tpl file. Without editing the tpl file, I cannot position the records in the correct part of the script
But if the .tpl file, which accepts html, could read the PHP data, I'd be able to move on with this mod i am creating. Sadly, I do not know
how to do this, despite trying to use .htaccess to turn .tpl and even .html (the outputted file which includes the template file contents)
into php pages.
That's my dilema and that's why I tried to use img src tags to display the data.
Thanks
The file 'viewrecords.php' has the list of them. But what if you need a cross browser solution to display those records, from viewrecords.php,
in the .tpl file?
I figured using img src tag would do that. I was wrong
So, in essence, I need to know how to get the darn .tpl file to display the records. I have a php file that runs this script
which reads the .tpl file. Without editing the tpl file, I cannot position the records in the correct part of the script
But if the .tpl file, which accepts html, could read the PHP data, I'd be able to move on with this mod i am creating. Sadly, I do not know
how to do this, despite trying to use .htaccess to turn .tpl and even .html (the outputted file which includes the template file contents)
into php pages.
That's my dilema and that's why I tried to use img src tags to display the data.
Thanks
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Getting PHP Data To Load Through IMG SRC Tag?
I have no idea where you are getting img tags from.. from what you've told me it doesn't sound like you want an image, just a simple list?
Can you post the contents of your 2 files?
Can you post the contents of your 2 files?
Re: Getting PHP Data To Load Through IMG SRC Tag?
Sure, thanks
File #1: TPL File:
http://www.ipngenerator.com/templates/list.txt
The PHP code is near the very bottom. It's an include file
The PHP code is:
http://www.ipngenerator.com/templates/viewlink.txt
Main Dilema
This is a link directory script. And a file called .directory is enabled to handle php. It creates dynamic directories and html files
such as this file:
http://www.ipngenerator.com/linkdir/dir ... /index.htm
That directory doesn't literally exist, though. So, index.html will OUTPUT the template files, including the code in file 1
But I have no way, even when I enable PHP through html, to get THAT code from file1 to DYNAMICALLY display
the code from file 2 (listed above)
I can get html to display PHP if I know the path. But since the html files are dynamic and cannot be hard coded through .htaccess,
I am forced to find a way to get php code to appear through that include statement listed in the bottom of file 1
I just don't know if this is possible. To allow viewers to use this script, view the dynamically created html file
and see a list of 10 links, which is generated from the code of file #2
I would pay $50 if I had a solution lol
Thanks for taking the time to help me. This is one of the few things that just baffles me to no end and it's killing me
File #1: TPL File:
http://www.ipngenerator.com/templates/list.txt
The PHP code is near the very bottom. It's an include file
The PHP code is:
http://www.ipngenerator.com/templates/viewlink.txt
Main Dilema
This is a link directory script. And a file called .directory is enabled to handle php. It creates dynamic directories and html files
such as this file:
http://www.ipngenerator.com/linkdir/dir ... /index.htm
That directory doesn't literally exist, though. So, index.html will OUTPUT the template files, including the code in file 1
But I have no way, even when I enable PHP through html, to get THAT code from file1 to DYNAMICALLY display
the code from file 2 (listed above)
I can get html to display PHP if I know the path. But since the html files are dynamic and cannot be hard coded through .htaccess,
I am forced to find a way to get php code to appear through that include statement listed in the bottom of file 1
I just don't know if this is possible. To allow viewers to use this script, view the dynamically created html file
and see a list of 10 links, which is generated from the code of file #2
I would pay $50 if I had a solution lol
Thanks for taking the time to help me. This is one of the few things that just baffles me to no end and it's killing me
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Getting PHP Data To Load Through IMG SRC Tag?
It would appear your template file contains syntax specific to a template engine, such as Smarty or TemplateLite.
Generally, your php file will load the template and iterate over the block in the template with the dynamic values using the template engine.
In light of your offer, I would suggest you post your requirements in our Job Hunt Forum
Generally, your php file will load the template and iterate over the block in the template with the dynamic values using the template engine.
In light of your offer, I would suggest you post your requirements in our Job Hunt Forum
Re: Getting PHP Data To Load Through IMG SRC Tag?
I will consider the job offer forum. But is there a resource to learn how to work with it? Is my request even possible, physically?
Thanks for your time. Just curious...
edit: Seems to use something called Fasttemplate.php
Joel
Thanks for your time. Just curious...
edit: Seems to use something called Fasttemplate.php
Joel
Last edited by jbh on Fri Mar 28, 2008 12:24 pm, edited 1 time in total.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Getting PHP Data To Load Through IMG SRC Tag?
Yes, your request is very possible. I would suggest you take a look at the millions of tutorials on Smarty.jbh wrote:I will consider the job offer forum. But is there a resource to learn how to work with it? Is my request even possible, physically?
Thanks for your time. Just curious...
Joel
Re: Getting PHP Data To Load Through IMG SRC Tag?
Will do. TY and enjoy your weekend, man.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Getting PHP Data To Load Through IMG SRC Tag?
I didn't notice your edit saying it was FastTemplate engine. However, I would suggest using TemplateLite or Smarty (in that order)

Np. You toojbh wrote:Will do. TY and enjoy your weekend, man.
Re: Getting PHP Data To Load Through IMG SRC Tag?
Oh, that's the problem. I should have made it clear, for those who might experience this too.
I am editing something somebody else created. He's off the face of the earth, apparently.
If I find a fix I'll post it here, as I figure the ability will be of use to somebody. Thanks again.
I am editing something somebody else created. He's off the face of the earth, apparently.
If I find a fix I'll post it here, as I figure the ability will be of use to somebody. Thanks again.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Getting PHP Data To Load Through IMG SRC Tag?
Try posting the code for FastTemplate.php (if its really long upload it). We'll see if it's simple enough to use..
I still suggest you use the other template engines though..
I still suggest you use the other template engines though..