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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old October 8th, 2004, 08:02 AM
mikemac mikemac is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Greenville NC
Posts: 70 mikemac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 15 m 24 sec
Reputation Power: 4
Any Ideas?

I want a certain row to be seen only by administrators. So I run a query. And "0" = user and "1"=administrator. And it always shows the field regardless of query results,whats wrong? Heres the code.

<!---Run query on variable and set variable to output of query--->
<CFQUERY name="info" datasource="LearningCenter">
SELECT Admin
FROM user
WHERE UserID="#UserID#"
</CFQUERY>
<cfoutput query="info">
<cfset Admin=info.Admin>
</cfoutput>

<!--- test to see if Admin--->
<CFIF "#Admin#" GT 0>
<CFOUTPUT>
<TR bgcolor="cccccc">
<td>
<strong>Administrator:</strong>
</td>
<td>
<select name="Admin">
<option value="0" selected>No </option>
<option value="1">Yes</option>
</select>
</td>
<td></td>
</tr>
</CFOUTPUT>
</cfif>

<!---theres got to be a better way. Being a newbie at any language is rough. you make long ineffective code. Any help is greatly appreciated--->

Reply With Quote
  #2  
Old October 8th, 2004, 09:04 AM
CfFreelancer CfFreelancer is offline
CF Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Long Island, NY
Posts: 34 CfFreelancer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 29 m 50 sec
Reputation Power: 5
try this

<!---Run query on variable and set variable to output of query--->
<CFQUERY name="info" datasource="LearningCenter">
SELECT Admin
FROM user
WHERE UserID="#UserID#"
</CFQUERY>




<cfoutput query="info">
<!--- test to see if Admin--->
<CFIF Admin GT 0>
<TR bgcolor="cccccc">
<td>
<strong>Administrator:</strong>
</td>
<td>
<select name="Admin">
<option value="0" selected>No </option>
<option value="1">Yes</option>
</select>
</td>
<td></td>
</tr>
</cfif>
</CFOUTPUT>

Reply With Quote
  #3  
Old October 8th, 2004, 11:16 AM
mikemac mikemac is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Greenville NC
Posts: 70 mikemac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 15 m 24 sec
Reputation Power: 4
Question still showing the field

Quote:
Originally Posted by CfFreelancer
<!---Run query on variable and set variable to output of query--->
<CFQUERY name="info" datasource="LearningCenter">
SELECT Admin
FROM user
WHERE UserID="#UserID#"
</CFQUERY>




<cfoutput query="info">
<!--- test to see if Admin--->
<CFIF Admin GT 0>
<TR bgcolor="cccccc">
<td>
<strong>Administrator:</strong>
</td>
<td>
<select name="Admin">
<option value="0" selected>No </option>
<option value="1">Yes</option>
</select>
</td>
<td></td>
</tr>
</cfif>
</CFOUTPUT>



It is still showing the field. The reason I want to hide it from non admin's is because ofcourse only admins should be able to assign other people as admins. This page is where all people sign up and having that field visible to all would be bad.

Reply With Quote
  #4  
Old October 8th, 2004, 11:48 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,611 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 9 h 10 m 21 sec
Reputation Power: 53
What about this? This should work if the Admin field is 0 or 1.

<!---Run query on variable and set variable to output of query--->
<CFQUERY name="info" datasource="LearningCenter">
SELECT Admin
FROM user
WHERE UserID="#UserID#"
</CFQUERY>

<CFIF info.recordcount gt 1>
More than 1 user returned for that user id!!
<cfabort>
</cfif>


<!--- test to see if Admin--->
<CFIF info.Admin eq 1>
<TR bgcolor="cccccc">
<td>
<strong>Administrator:</strong>
</td>
<td>
<select name="Admin">
<option value="0" selected>No </option>
<option value="1">Yes</option>
</select>
</td>
<td></td>
</tr>
</cfif>
__________________
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
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Any Ideas?


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