ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 14th, 2005, 03:32 PM
Caden Caden is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 270 Caden User rank is Private First Class (20 - 50 Reputation Level)Caden User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 6 h 57 m 16 sec
Reputation Power: 4
CF Logic

I need some advice on how I should logically approach something. I'll try to make what I'd like to do as clear as possible...here goes.

So, i've got a page. And on that page I have pictures and text loading from a database.

The idea is that using admin controls I can easily change what is being shown on the page, insted of actually changing the HTML code.

So, for example, I have 4 entries in the database, 2 of them are being shown. I have a field in the database called show, if there is anything in the show field, they are shown, if there is nothing in the show field, they aren't shown. Easy enough.

My problem arises in the way i'm doing it, which is probably a very bad way, but it was the first thing I came up with, I tried it, it worked, now i'd like to refine my thinking.

Esentially, I want to show these items, so I have a field called show as stated above, but in the show field, I have numbers, 1-2-3. Because I want the ability to hold many records in the database, but only show 2 or 3 at a time, it pulls information based on the show field. Then to "show" the text and pictures, I use a query, and an output query where the start row is either 1-2-3 and the max row is 1.

This way, the returned records aren't shown all at once, like in a gallery situation, where you might see 10 items in 2 rows of 5, I didn't want that. I wanted to be able to control where the pictures and text are, etc.

This creates a couple more problems. Firstly, what if the user puts two records with the number 1 in it, I haven't tested what would happen, but because show isn't the primary key, i'm unsure how to make show a unique field. And two, I think my logic sucks, and there must be a better way to streamline it.

Anyhow, I hope that makes sense, if it doesn't and you wish to help me I'll try to explain it better.

Thanks
Caden

Reply With Quote
  #2  
Old March 14th, 2005, 04:04 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Well the problem of the user entering two "number 1" values is easy, you must validate the user's data before you let it go into the database. In this case you'd make sure that there are no duplicates. You can do this manually (query the database first and make sure there isn't another record already in there), or apply a unique constraint on the column (see your database's documentation, and remember that any column can be set to unique not just the primary key).

I'm not clear on what the rest of your question is though. You say you are querying for what should show up on the page. That makes sense, so what's the problem?
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old March 14th, 2005, 04:10 PM
Caden Caden is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 270 Caden User rank is Private First Class (20 - 50 Reputation Level)Caden User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 6 h 57 m 16 sec
Reputation Power: 4
Ahh, validation, see, that's smart, for some reason, I never think about validating in reference to CF.

I suppose the 2nd part isn't really a problem, I just figure there had to be a better way.

So, insted of 3 output query's, which is what I have now
(start row 1-2-3, maxrow 1) etc, but, if that is an accepted fine way to do it, well, cool then, go me.

Reply With Quote
  #4  
Old March 14th, 2005, 04:48 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
You could also just limit what is coming out of the database in the SQL itself.

Reply With Quote
  #5  
Old March 15th, 2005, 09:50 AM
Caden Caden is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 270 Caden User rank is Private First Class (20 - 50 Reputation Level)Caden User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 6 h 57 m 16 sec
Reputation Power: 4
I've got a Ben Forta CF book - WACK fifth edition, but it only covers basic form field validation, and does not refer to validating based on an SQL query. And so far surfing the net the only thing I can find in reference to that would be to use the "cfqueryparam" tag.

If somebody could post an example or a URL to a good tutorial that would be terrific.

Thanks
Caden

Reply With Quote
  #6  
Old March 15th, 2005, 10:02 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
You could just put a unique constraint on the column, and then wrap your cfquery tag in a cftry/cfcatch block. If the database throws a "unique constraint violated" error when you try to insert a record you know that there is already a record there with the same number. When you catch the error you can have the application respond in any way, possibly redisplaying the form and giving the user an message about not duplicating things.

Reply With Quote
  #7  
Old March 15th, 2005, 10:33 AM
Caden Caden is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 270 Caden User rank is Private First Class (20 - 50 Reputation Level)Caden User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 6 h 57 m 16 sec
Reputation Power: 4
That's awesome, worked like a charm.

Thanks Kiteless!
Caden

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > CF Logic


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway