Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create a .gif or .png image from a database?

Status
Not open for further replies.

yangshuo

Programmer
Mar 9, 2001
2
CN
i want to create a .gif or .png image on server,so you can quicly see a image on browser .for example ,the stock chart. i don't want to use ActiveX or java .
please help me .
thank you.
 
I'm not sure if this is what you need, but here's what I have done.

I store the images themselves in the "Logos folder". I store the file name in my database. (e.g. warbirds.png).

I set an application variable to the path for the logos.
Code:
 <CFSET application.LogoPath=&quot;../CommonFiles/TollgradeImages/Logos/&quot;>
When I want to display the image, I query the database to get the file name, then tack it onto Application.LogoPath, and display the image. Here is some code to show you what I mean.

This page queries my database, and presents the user with a list of teams with their logos and a brief description of what eash team does. I made the images clickable, so the user can click on a logo and get more detailed information about the team.
Code:
<!--- This reads the Team database. --->
<cfquery name=&quot;TeamList&quot;
         datasource=&quot;#Application.Datasource#&quot;
         maxrows=20
         dbtype=&quot;ODBC&quot;>
	SELECT	TeamName, TeamLogoLocation, TeamDescription, TeamID
	FROM 	TeamTable
</cfquery>


<!--- This outputs the team information. --->

<cfoutput query=&quot;TeamList&quot;>
<P>
	<INPUT TYPE=&quot;HIDDEN&quot; NAME=&quot;TeamSelected&quot; VALUE=<img src=&quot;#TeamLogoLocation#&quot;>
		<!--- This creates a clickable image and sets URL.Team to be passed to the next page.--->	
		<A HREF=&quot;TeamActionPage.cfm?Team=#TeamList.TeamID#&quot;>
			<img src=&quot;#Application.LogoPath##TeamLogoLocation#&quot; width=&quot;64&quot; height=&quot;64&quot; align=&quot;left&quot; border=&quot;0&quot; alt=&quot;&quot;></a> 
		<!--- Here is the link from the team name and also sets URL.Team to be passed to the next page. --->
		<b><font size=&quot;+1&quot;><A HREF=&quot;TeamActionPage.cfm?Team=#TeamList.TeamID#&quot;>#TeamName#</A><BR> </font></b>
		<!--- Output team description. ---> 
		#TeamDescription#<br clear=&quot;left&quot;>
</P>
</cfoutput>

This is part of the more detailed page. The team ID was passed from the page above.

Code:
<!--- This query retreives the logo of the team the user selected. &quot;URL.Team&quot; was passed from TeamList.cfm --->
<cfquery name=&quot;GetTeamLogo&quot;
         datasource=&quot;#Application.Datasource#&quot;
         dbtype=&quot;ODBC&quot;>
SELECT   TeamID, TeamLogoLocation, TeamName
FROM      TeamTable
WHERE   TeamID = '#URL.Team#'
</cfquery>

<P>
<cfoutput query=&quot;GetTeamLogo&quot;>
	<img align=&quot;absmiddle&quot; src=&quot;#Application.LogoPath##TeamLogoLocation#&quot; width=&quot;64&quot; height=&quot;64&quot; border=&quot;0&quot; alt=&quot;&quot;>
</cfoutput> 
<cfoutput><font size=&quot;+2&quot;><b>Active Projects</b></font></cfoutput><br>
</P>

Hope this helps! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top