click to download an image

Discussion in 'Programming' started by cumupkid, Feb 7, 2008.

  1. #1
    I want to have an option for people to click to download images from my MySql database.

    Code:

    <cfset CurrentPage=GetFileFromPath(GetBaseTemplatePath())>
    <cfparam name="PageNum_rsPhoto" default="1">
    <cfquery name="rsPhoto" datasource="intheworksphotoco">
    SELECT *
    FROM photos
    ORDER BY PHOTOID DESC
    </cfquery>
    <cfset MaxRows_rsPhoto=1>
    <cfset StartRow_rsPhoto=Min((PageNum_rsPhoto-1)*MaxRows_rsPhoto+1,Max(rsPhoto.RecordCount,1))>
    <cfset EndRow_rsPhoto=Min(StartRow_rsPhoto+MaxRows_rsPhoto-1,rsPhoto.RecordCount)>
    <cfset TotalPages_rsPhoto=Ceiling(rsPhoto.RecordCount/MaxRows_rsPhoto)>
    <cfset QueryString_rsPhoto=Iif(CGI.QUERY_STRING NEQ "",DE("&"&XMLFormat(CGI.QUERY_STRING)),DE(""))>
    <cfset tempPos=ListContainsNoCase(QueryString_rsPhoto,"PageNum_rsPhoto=","&")>
    <cfif tempPos NEQ 0>
    <cfset QueryString_rsPhoto=ListDeleteAt(QueryString_rsPhoto,tempPos,"&")>
    </cfif>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <!-- DW6 -->
    <head>
    <!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->

    <title>Photo Gallery</title>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="../assets/intheworks.css" type="text/css" />
    </head>

    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr bgcolor="02021e">
    <td colspan="4" rowspan="2" nowrap="nowrap" bgcolor="#02021E"><img src="../assets/intheworks_pg_ban.jpg" alt="Header image" width="400" height="140" border="0" /></td>
    <td height="58" colspan="4" valign="bottom" nowrap="nowrap" bgcolor="#02021E" id="logo">In The Works Photo Co.</td>
    </tr>
    <tr bgcolor="02021E">
    <td height="57" colspan="4" valign="top" nowrap="nowrap" bgcolor="#02021E" id="tagline">Photos By Independent Photographer Jermey Wilson</td>
    </tr>
    <tr>
    <td colspan="8" bgcolor="#cc3300"><img src="../assets/intheworks_spacer.gif" alt="" width="1" height="2" border="0" /></td>
    </tr>

    <tr>
    <td colspan="8"><img src="../assets/intheworks_spacer.gif" alt="" width="1" height="2" border="0" /></td>
    </tr>

    <tr>
    <td colspan="8" bgcolor="#cc3300"><img src="../assets/intheworks_spacer.gif" alt="" width="1" height="1" border="0" /></td>
    </tr>

    <tr>
    <td colspan="8">&nbsp;&nbsp;<br /> </td>
    </tr>
    <tr>
    <td valign="top" height="370">
    <table border="0" cellspacing="0" cellpadding="0" width="160" id="navigation">
    <tr>
    <td height="40"><a href="../index.html">Home</a></td>
    </tr>
    <tr>
    <td height="40"><a href="index.cfm">photo gallery</a></td>
    </tr>
    <tr>
    <td height="40"><a href="../aboutme/index.html">about me</a></td>
    </tr>
    <tr>
    <td height="40"><a href="../contactme/index.html">contact me</a></td>
    </tr>
    <tr>
    <td height="40"><a href="../admin/login.cfm">login</a></td>
    </tr>
    </table>
    <br /></td>
    <td width="1" rowspan="2" bgcolor="#445DA0">&nbsp;</td>
    <td height="400" colspan="5" align="left" valign="top">
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <th height="40" class="pageName">Photo Gallery</th>
    </tr>
    </table>
    <table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td align="center"><a href="thumnail_gallery.cfm">View small Images</a></td>
    </tr>
    </table>
    <cfoutput query="rsPhoto" startRow="#StartRow_rsPhoto#" maxRows="#MaxRows_rsPhoto#">
    <table width="600" border="0" align="center" cellpadding="0" cellspacing="0" class="subHeader">
    <tr>
    <td height="35" colspan="3" class="subHeader">#rsPhoto.PHOTONAME#</td>
    </tr>
    <tr>
    <td width="75" height="250" align="center">&nbsp;</td>
    <td width="450" align="center" bgcolor="##000000"><img src="../images/#rsPhoto.LARGEIMAGE#" width="400" height="200" longdesc="../images/aiden01.jpg" /></td>
    <td width="75" align="center">&nbsp;</td>
    </tr>
    <tr>
    <td height="50" align="center">&nbsp;</td>
    <td height="50" align="center"><span class="bodyText">#rsPhoto.DISCRIPTION#</span></td>
    <td height="50" align="center">&nbsp;</td>
    </tr>
    <tr>
    <td colspan="3" align="center" background="../assets/blue_spacer.gif">&nbsp;</td>
    </tr>
    </table>
    </cfoutput> <table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr align="center">
    <td width="120"><cfif PageNum_rsPhoto GT 1>
    <a href="<cfoutput>#CurrentPage#?PageNum_rsPhoto=1#QueryString_rsPhoto#</cfoutput>">First</a>
    </cfif></td>
    <td width="120"><cfif PageNum_rsPhoto GT 1>
    <a href="<cfoutput>#CurrentPage#?PageNum_rsPhoto=#Max(DecrementValue(PageNum_rsPhoto),1)##QueryString_rsPhoto#</cfoutput>">Previous</a>
    </cfif></td>
    <td width="120" class="contentheaderSm">&nbsp;<cfoutput>#StartRow_rsPhoto#</cfoutput> of <cfoutput>#rsPhoto.RecordCount#</cfoutput></td>
    <td width="120"><cfif PageNum_rsPhoto LT TotalPages_rsPhoto>
    <a href="<cfoutput>#CurrentPage#?PageNum_rsPhoto=#Min(IncrementValue(PageNum_rsPhoto),TotalPages_rsPhoto)##QueryString_rsPhoto#</cfoutput>">Next</a>
    </cfif></td>
    <td width="120"><cfif PageNum_rsPhoto LT TotalPages_rsPhoto>
    <a href="<cfoutput>#CurrentPage#?PageNum_rsPhoto=#TotalPages_rsPhoto##QueryString_rsPhoto#</cfoutput>">Last</a>
    </cfif></td>
    </tr>
    </table></td>
    <td width="183" valign="top"><table width="160" border="0" align="right" cellpadding="0" cellspacing="0">
    <tr>
    <td id="sidebarHeader" class="sidebarHeader" align="center">Side notes and/or latest info</td>
    </tr>
    <tr>
    <td align="center"><p><img src="" alt="Picture place holder" name="picture" width="110" height="110" id="picture" style="background-color: #99CCFF" /><br />
    Discription<br />
    <a href="javascript:;">read more &gt;</a></p>
    <p><img src="" alt="Picture place holder" name="picture" width="110" height="110" id="picture2" style="background-color: #99CCFF" /><br />
    Discription<br />
    <a href="javascript:;">read more &gt;</a></p>
    <p>&nbsp;</p></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td width="160"><p><br />
    </p></td>
    <td width="152">&nbsp;</td>
    <td width="87">&nbsp;</td>
    <td width="413">&nbsp;</td>
    <td width="48">&nbsp;</td>
    <td width="188">&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td bgcolor="#445DA0">&nbsp;</td>
    <td height="10" colspan="5" align="center"><span class="siteby">This site designed &amp; maintained by</span> <a href="mailto:jstickel56@gmail.com">Joseph Stickel</a></td>
    <td>&nbsp;</td>
    </tr>
    </table>
    </html>
     
    cumupkid, Feb 7, 2008 IP