Discussion:
dynamic image woes
(too old to reply)
rockhiker
2009-03-02 16:20:01 UTC
Permalink
hi again, I made your suggested corrections to my code and there are no error
messages, however, no images display on the details page.

<!---change the query on page 3 details page--->

SELECT thumb
FROM completeImages
WHERE projectID = <cfqueryparam cfsqltype="cf_sql_integer"
value="#url.projectID#">

<!--- change the link on page 2 --->

&projectID=#cool.projectID#"
Azadi
2009-03-02 16:40:30 UTC
Permalink
1) add <cfdump var="#cool#"> right after the query on page 3
2) check the query dump - did it return any data (images)?
if it did - the problem is with your code that displays the images, not
the query.
if it did not - check the value of projectID in the url - is it what you
expect it to be? (i have just guessed/assumed that #cool.projectID# on
your page 2 would be the correct projectID - maybe i was wrong?)
i have also assumed your projectID column is of type imteger/numeric -
if it is not, then change the cfsqltype to cerrect one in the
<cfqueryparam> tag...

if all else fails - post all relevant code from your page 3.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
rockhiker
2009-03-02 17:09:18 UTC
Permalink
It works !!! I changed the query to

SELECT thumb
FROM completeImages
WHERE projectID = <cfqueryparam cfsqltype="cf_sql_integer"
value="#url.projectID#">

and I changed the link to: &projectID=#cool.projectID#"


I am trying to dispaly an images unavailabe message if there are no images in
the database. pls see code.

<cfoutput query="coolpicx">
<cfif #thumb# EQ " ">

<img src="/crabweb1a/Images/CompleteProjectImages/completeThmbs/#thumb#"/>
<cfelse>
Images unavailable
</cfif>
</cfoutput>
Ian Skinner
2009-03-02 17:34:56 UTC
Permalink
Post by rockhiker
<cfif #thumb# EQ " ">
<cfif thumb EQ "">

No data in a field will be an empty string not a single space character.
Azadi
2009-03-03 05:49:19 UTC
Permalink
as Ian has mentioned, correct condition in your cfif should be:
<cfif thumb eq ""> or <cfif len(trim(thumb))>

but why don't you rather select only those records in your query that
have thumb to begin with? a lot more efficient to do it on db level than
checking each row at output...

depending on db you use, the function to use to check the length of
thumb column will be different. check you db manual for correct function
to use. the following will work in MySQL db:

<cfquery name="coolpicx" ...>
SELECT thumb
FROM ...
WHERE projectID = ... AND LENGTH(TRIM(thumb)) > 0
</cfquery>
<!--- or you could use CHAR_LENGTH(TRIM(thumb)) > 0 --->
<!--- just remember that these are DB functions, NOT cf functions! --->

that way your query will only select those records that do have a value
for THUMB. and you won;t need to do any checking at output. you can just do:

<cfoutput query="coolpicx">
<img src="/crabweb1a/Images/CompleteProjectImages/completeThmbs/#thumb#"/>
</cfoutput>
<cfif coolpicx.recordcount is 0>
No images to display, sorry...
</cfif>

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
rockhiker
2009-03-03 17:52:18 UTC
Permalink
thank yous - I will give that a try.

Loading...