Skip to main content
Participating Frequently
June 17, 2011
Question

Need Coldfusion Help, please =)

  • June 17, 2011
  • 3 replies
  • 2306 views

I am helping a woman out with a small website that is set up with coldfusion. She adds photos with a coldfusion application that was written by someone. I am not too experienced with coldfusion, but have used it, so I was wondering if someone could help me out!

First - She wants her list of photos to be arranged by date added. So the most recent ones at the top. I assume this is done in the <cfoutput> tag but I am not quite sure on the syntax?

Second - She wants to be able to hide some from showing on her website in case people aren't paying her then they will not show up on the website. But if people pay her to show images of their work, then she doesn't want to have to keep adding and deleted them. If you need to see the code to help me out, I can definitely add post it.

Thank you!

This topic has been closed for replies.

3 replies

Inspiring
July 15, 2011

To see your table field names do this:

<cfquery name="colList" datasource="yourDatasource">

  Select *

  From yourTableName

  Where 0=1

</cfquery>

This will return zero records.

<br />

<cfdump var="colList" />

While this won't give you data type or length you should be able to determine the name of the date field you are trying to order the set by.

Inspiring
July 15, 2011
To see your table field names do this:

<cfquery name="colList" datasource="yourDatasource">

  Select *

  From yourTableName

  Where 0=1

</cfquery>

This will return zero records.

<br />

<cfdump var="colList" />

While this won't give you data type or length you should be able to determine the name of the date field you are trying to order the set by.

There's also CFDBINFO which would probably be a better and more comprehensive solution to this requirement.  That said, the OP doesn't say one way or the other, but I don't think CFDBINFO works on Access DBs (but who cares?), and obviously only works on CF8+.  But all DBs have things like SP_HELP or DESCRIBE which do a better job of fetching this info that the SELECT * route.

--

Adam

Inspiring
June 17, 2011

For arranging the photos by the date, use an order by clause in your query.  Cfoutput is not the best way to approach this.

For only displaying paid for images, if you have the data, use it in the where clause of your query.  If you don't, you have to create a spot in the database to put it, and come up with a way to maintain that data.

In short, the solution to both problems lie with your data, not Coldfusion code.

jodifay12Author
Participating Frequently
June 17, 2011

The following is the page for the image listings that she wants ordered. If I just use a simple ORDER BY clause under the SELECT statement, I thought this would solve my problem, but I get an error message. I tried "ORDER BY date desc".


As I stated I am very new to the use of coldfusion and felt I wasn't taught well in the first place, so I am just trying to figure it out on my own via books and internet. I appreciate your help and your patience with me as I am new to this!

Secondly. what I highlighted in red is where I get confused as to why it does not work with the photos being "active". If no is marked, the photo is still visible on the website.


<cfquery name="getIdeas" datasource="#datasource#" username="#username#" password="#password#">
SELECT *
FROM dbo.ideas
</cfquery>
<cfparam name="url.status" default="none">

<!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"><!-- InstanceBegin template="/Templates/utilities.dwt.cfm" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>LakesAreaCelebrations.com - Utilities - Edit / Delete an Idea Listing</title>
<script type="text/javascript" src="../scripts/sortable.js"></script>
<!-- InstanceEndEditable -->
<link href="../styles/main.css" rel="stylesheet" type="text/css" />
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>

<body>
<p class="greylargebold">LakesAreaCelebrations.com Utilities</p>
<p><a href="../index.cfm">Return to Utilities Home Page</a><br />
  <a href="../../index.cfm">View LakesAreaCelebrations.com Home Page</a></p>
<!-- InstanceBeginEditable name="pageBody" -->
<cfif url.status is "Deleted">
<script>
alert('Listing Deleted');
</script>
</cfif>
<div align="center"><span class="greylargebold">Select the Idea Listing to Edit or Delete</span><br />
  <br />
  <a href="index.cfm">add another listing</a><br />
  <br />
  <table width="100%" id="sortableTable" class="sortable">
    <tr>
      <th width="15%" class="heading noBorder">Image Name</th>
      <th width="16%" class="heading noBorder">Title</th>
      <th width="14%" class="heading noBorder">Contributor</th>
      <th width="9%" class="heading noBorder">Is Active?</th>
      <th width="8%" class="heading noBorder"> </th>
      <th width="5%" class="heading noBorder"> </th>
    </tr>
    <cfoutput query="getIdeas">
    <tr>
        <td align="left"><cfif getIdeas.I_Image is not "">#getIdeas.I_Image#<cfelse><span style="color:##FF0000;">No Image</span></cfif></td>
        <td align="left">#getIdeas.I_Title#</td>
        <td align="left">#getIdeas.I_ContributedBy#</td>
        <td align="left"><cfif getIdeas.I_IsActive is "1">
          Yes
          <cfelse>
          No
        </cfif></td>

        <td align="left"><a href="index.cfm?I_UId=#getIdeas.I_UId#">edit</a></td>
        <td align="left"><a href="ideaDelete.cfm?I_UId=#getIdeas.I_UId#">delete</a></td>
    </tr>
        </cfoutput>
  </table>
</div>
<!-- InstanceEndEditable -->
</body>

Inspiring
June 17, 2011

What did the error message say?

Inspiring
June 17, 2011

I am helping a woman out with a small website that is set up with coldfusion. She adds photos with a coldfusion application that was written by someone. I am not too experienced with coldfusion, but have used it, so I was wondering if someone could help me out!

Help with problems yuo are having writing your own code: yes.  Writing your code for you: no.

It helps when posting here if you post the code you have tried, and tell us where you're having problems.

First - She wants her list of photos to be arranged by date added. So the most recent ones at the top. I assume this is done in the <cfoutput> tag but I am not quite sure on the syntax?

Well: yes and no. CFOUTPUT can be used for iterating over a record set, yes.  Although in most situations, CFLOOP is a better fit for that job.

But anyway, before you loop over a record set, you need to GET the record set, so you have to ask the database for it (I'm assuming this stuff is in a database, although you don't say).

So you need to use CFQUERY or CFSTOREDPROC to pass instructions to the DB telling it what and how you want it.

Second - She wants to be able to hide some from showing on her website in case people aren't paying her then they will not show up on the website. But if people pay her to show images of their work, then she doesn't want to have to keep adding and deleted them.

This is a DB design question (or "issue").  The record set you want to fetch from the DB needs to be queried in such a way that you only select the image records which have a corresponding "person" who has an account that is flagged as being "paid".

Without knowing your DB schema, it's impossible to say how to effect this.

I think you probably need to find some CF and DB/SQL tutorials or books or whatever and work your way through those before you start working on someone's website, to be honest.

However if you've got some CF code and it's not doing what you want it to, post the code, and post a description of how it's not working: what it's doing wrong, and what your expectations are.

--

Adam