Stuart,
I've built some data driven photo galleries. I will assume you're going to use
Access (yuck!) :)
Build a table called tblimagegallery
field 1: imageid autonumber(Access)
field 2: image text (if it's going to be less than 255 chars
field 3: imagecaption
Here's the add_imagegallery.cfm page:
<cfset numberoffields = 10>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<cfif IsDefined("URL.upload")>
<h3 align="center">Images successfully uploaded</h3>
</cfif>
<h3 align="center">Add images and captions to your photo gallery page</h3>
<p align="center"><form action="process_imagegallery.cfm"
enctype="multipart/form-data" method="post">
<cfloop index="i" from="1" to="#variables.numberoffields#" step="1">
<cfset filename = "file" & i>
<cfset titlename = "title" & i>
<cfset placename = "place" & i>
<input type="File" name="<cfoutput>#variables.filename#</cfoutput>">
Caption:
<input name="<cfoutput>#variables.titlename#</cfoutput>" type="text"
size="50" maxlength="255">
</cfloop>
<div align="center"><br>
<input type="Submit" name="upload" value="upload">
</div>
</form></p>
And here's the processing page:
<cfset numberoffields = 10>
<cfloop index="i" from="1" to="#variables.numberoffields#" step="1">
<cfset filename = "form.file" & i>
<cfset titlename = "form.title" & i>
<cfset theplace = "form.place" & i>
<cfif evaluate(variables.filename) neq "">
<cffile action="UPLOAD" accept="image/pjpeg, image/jpg, image/jpeg,
image/png, image/gif, image/pjpg"
destination="D:/inetpub/wtomlinson/milaimages" nameconflict="OVERWRITE"
filefield="#variables.filename#">
<cfquery datasource="#DSN#">
INSERT INTO tblimagegallery
(image, imagecaption, imageplace)
VALUES
('#File.ServerFile#', '#evaluate(variables.titlename)#')
</cfquery>
</cfif>
</cfloop>
<cflocation url="add_imagegallery.cfm?upload=yes">
</body>
</html>
And here's the display page(format it how you like):
<cfquery name="getphotos" datasource="#DSN#">
SELECT imageid, image, imagecaption FROM tblimagegallery
</cfquery>
<table width="100%" height="389" border="0" align="center" cellpadding="0"
cellspacing="4">
<tr>
<td valign="top" bgcolor="#EEEEEE"> <table width="100%" border="0"
cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top"></td>
<td> </td>
</tr>
</table>
<table width="100%" cellpadding="0">
<tr> <cfoutput query="getphotos">
<td height="90" bgcolor="##FFFFFF">
<div align="center">
<cfif getphotos.imagecaption NEQ "">
<p>#getphotos.imagecaption#</p>
<cfelse>
<p></p>
</cfif>
<p><a href="milaimages/#getphotos.image#" target="_blank"><img
src="milaimages/#getphotos.image#" alt="Click for a larger view" width="200"
height="150"></a>
</p>
<br>
</div></td>
<cfscript>
if (getphotos.CurrentRow mod 3 eq 0 AND NOT getphotos.CurrentRow eq
getphotos.RecordCount) {
writeoutput("</tr><tr>");
}
</cfscript>
</cfoutput></tr>
</table>
<br> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
</table></td>
</tr>
</table>
I modified the code a little to make it more generic, so I might've errored
somewhere, but this should work.
Will
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:185385
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54