Skip to main content
Known Participant
September 15, 2006
Answered

Cfif and displaying images.

  • September 15, 2006
  • 2 replies
  • 321 views
Here the issue.

My company has an Events page user put events onto it.
Well If the company is runing it my boss wants to show an image.


The yes/ no or true /false will come from an admin form.
So what would the <cfif> look like?

<cfif (yes)>
<img src="image.jpg">
</cfif>

I think that is close not sure what does between <cfif> and (yes) though.

Thanks for the help
This topic has been closed for replies.
Correct answer azadisg
the cfif clause will absolutely depend on the database structure, if you are using a database. i presume you are, as you must be storing the event info somewhere, although you could be doing it in a text file, too...

basically, you will have to check for the value of the field (db column) that stores the yes/no value for the clause "is event run by company".

so if, for example, your 'events' table stores the yes/no answer from the admin form in a 'is_run_by_company' column, then in the page that displays events:

<!--- get even data: --->
<cfquery name='getEvents' datasource='yourDSN'>
SELECT * FROM events
</cfquery>

<!--- show even info --->
<cfoutput query='getevents'>
.....
<cfif getEvents.is_run_by_company is true><img scr='image.jpg'></cfif>
....
</cfoutput>

if you do not understand the above, then post your code here. post both the page that enteres event data into db and the page that displays even data on screen. just the db queries and forms will do - no need for other code on the pages.

2 replies

Exmachin4Author
Known Participant
October 6, 2006
Sorry took me so long to reply.

It worked perfectly. Thank for the help!
azadisgCorrect answer
Inspiring
September 16, 2006
the cfif clause will absolutely depend on the database structure, if you are using a database. i presume you are, as you must be storing the event info somewhere, although you could be doing it in a text file, too...

basically, you will have to check for the value of the field (db column) that stores the yes/no value for the clause "is event run by company".

so if, for example, your 'events' table stores the yes/no answer from the admin form in a 'is_run_by_company' column, then in the page that displays events:

<!--- get even data: --->
<cfquery name='getEvents' datasource='yourDSN'>
SELECT * FROM events
</cfquery>

<!--- show even info --->
<cfoutput query='getevents'>
.....
<cfif getEvents.is_run_by_company is true><img scr='image.jpg'></cfif>
....
</cfoutput>

if you do not understand the above, then post your code here. post both the page that enteres event data into db and the page that displays even data on screen. just the db queries and forms will do - no need for other code on the pages.