Hi, John... I had to forward my last message below because
I'm getting the "digest" version of the mailing list for
cf-newbie and it didn't go through.  Read the following post
and let me know if you have any questions.

Rick


> -----Original Message-----
> From: Rick Faircloth [mailto:[EMAIL PROTECTED]
> Sent: Sunday, November 25, 2007 8:48 AM
> To: '[email protected]'
> Subject: RE: ColdFusion Newbie (CF-Newbie): Digest every hour
> 
> Hi, John.
> 
> This is definitely worth learning!  You'll never want to build
> another static rather than dynamic website after your first, so keep at it!
> 
> I'm not sure I understand what happened when you ran the code:
> <cfoutput>
> #GetArticle.Text#
> </cfoutput>
> 
> That should have only output one article's text.  On the other hand,
> if you run this code:
> 
> <cfoutput query="GetArticle">
> #Text#
> </cfoutput>
> 
> You'll get the text for every article, as the statement
> <cfoutput query="GetArticle"> loops through the entire group of records
> returned by the query "GetArticle".
> 
> If you're just trying to always gets the first article in your database, which
> would be the first row, then you could set up your query like this:
> 
> <cfquery name="getarticle" database"(yourdatabasename)">
> 
> select text from articles limit 1
> 
> </cfquery>
> 
> Now, that works with MySQL database, which I've used for years.
> 
> My table structure would be (and is when I do this):
> 
> article_id
> article_title
> article_text
> article_byline
> article_author
> author_name
> author_title
> author_photo
> date_entered
> 
> That gives me everything I need for a nice article display.  It's not 
> necessary
> to have all that; it just works well for my websites.
> 
> I get the feeling that you're wanting to be able to select specific
> articles, rather than just the first one you entered all the time.  Would 
> that be correct?
> 
> Are you wanting to get the *last* one entered or *last one updated*
> in the database?  I do this a lot for articles which clients enter.
> When they enter it a timestamp gets put in the table to show it was the
> last one entered.  If I want that article I use this query:
> 
> <cfquery name="getarticle" database="articles">
> select title, text from articles order by date_entered desc limit 1
> </cfquery>
> 
> Now, there's a lot more in that query, but let's break it down...
> 
> First, this part "select title, text from articles" is just selecting
> the title and text from the target article.  I usually use those when
> putting the article on a website.
> 
> Next, the "order by date_entered"... "date_entered" is the row in my
> database table which has the timestamp for the article.  The timestamp
> is updated automatically whenever the article is entered or updated.  That
> way, the last article entered or updated always has the latest date.
> The "order by" by tell the query to return the records from the database
> ordered from first to last by whatever criteria I tell it to use; in this
> case it's "date_entered".
> 
> The next little part of the query that makes this work is the "desc" part.
> That tells the query not only to return the records in "descending order",
> in this case descending order by date_entered because of the the "order by
> date_entered" part.
> 
> And finally, the last part that makes this query return only 1 result from
> the query is the "limit 1" part.  Now, this works I MySQL databases, but my
> guess is, it would probably work in Access, if that's what you're using, too.
> 
> Let me know if this helps and if you need more help, tell me specifically,
> what database you're using, such as Access or MySQL, and how your database
> table is structured, meaning what columns of information you have in your
> database, tell me exactly what you want to accomplish with your query and
> display on your website, then finally, show me all the code you're using.
> 
> With all that information, we can get you the results you want.
> 
> I remember being exactly where you are about 10 years ago, so I know what
> you're going through.  It can all be very confusing at first.  But stick with
> it, it's worth it!  And ColdFusion is by far the easiest way to use basic
> functions all the way up to the most powerful!
> 
> Hope this helps!
> 
> Rick
> 
> 
> 
> 
> 
> > -----Original Message-----
> > From: cf-newbie [mailto:[EMAIL PROTECTED]
> > Sent: Sunday, November 25, 2007 4:00 AM
> > To: cf-newbie
> > Subject: ColdFusion Newbie (CF-Newbie): Digest every hour
> >
> >
> > ColdFusion Newbie (CF-Newbie)          25-Nov-07             Issue:618
> > In this issue:
> >      cf query
> >      cf query
> >
> > 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get the answers you are looking for on the ColdFusion Labs
Forum direct from active programmers and developers.
http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72&catid=648

Archive: 
http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:3163
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to