Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Questions on File exist and results output. 1

Status
Not open for further replies.

theevilone

IS-IT--Management
Aug 19, 2001
52
GB
Two questions.

1, I have a routine in my code, which checks if a certain image file exists. If it exists, it should display it, else, display a default image location. (code below). What happens is that, if it does find the image, it displays it, if it cannot, it still shows the same location, but without the image

<cfif &quot;../#category1name#/images/#test#&quot; neq &quot;&quot;>

<td width=&quot;70%&quot; rowspan=&quot;8&quot; align=&quot;center&quot;><img border=&quot;0&quot; src=&quot;../#category1name#/images/#test#&quot;></td>

<cfelse>
<td width=&quot;70%&quot; rowspan=&quot;8&quot; align=&quot;center&quot;><img border=&quot;0&quot; src=&quot;whitesquare400.jpg&quot;></td>
</cfif>


2, I have product numbers that are n4,n14, n15 . Database query (asc) results show the order as n14,n15,n4 . How can I get the results to sort the results correctly. I hope that makes sense.

Help. Thanks in advance.
 
1. If you've copy pasted into this message I can only say that what is written here should work. May be you've done this, but what does the source of the html page say when you look in it after executed your page? Another thing you can try is (put all of it in your source):

This is placed in the page and after this the if statement is executed:
<cfif &quot;../#category1name#/images/#test#&quot; neq &quot;&quot;>
Hello, then part!!
<td width=&quot;70%&quot; rowspan=&quot;8&quot; align=&quot;center&quot;><img border=&quot;0&quot; src=&quot;../#category1name#/images/#test#&quot;></td>
<cfelse>
Hello, else part!!
<td width=&quot;70%&quot; rowspan=&quot;8&quot; align=&quot;center&quot;><img border=&quot;0&quot; src=&quot;whitesquare400.jpg&quot;></td>
</cfif>
:This is placed in the page and after this the if statement is done


Look in the source again, look if you can find this and what part is executed. Maybe it will help.

2. Your problem is that you productId is from the type character, what means that all data is checked from left to right. Solution:

a. place '0' fore the numbers like: n04, n14

b. change your type from character to number (integer) and your keys will be 1,2,4..14..


I hope it will help, let me know,


Charl
 
On the first problem, your <cfif> will never be false because you're checking a string that will always have some characters in it. If both variables are blank, your string still evaluates to this &quot;..//images/&quot; which is not equal to &quot;&quot;. If you're wanting to determine if the file really exists in the directory, I would use the fileExists() function. You'll have to change the path to an absolute one but I think you'll have better luck this way.

<cfif fileExists(&quot;d:/ Show image code here....
<cfelse>
Show default image here...
</cfif>

If you just want to check to see if the directory or image name are blank, just modify your <cfif> like this.
<cfif category1name is &quot;&quot; or test is &quot;&quot;>

On the 2nd problem, there's no easy way to do this that I know of except change the values as RedLion suggests. I often add a special &quot;sort&quot; field that is numeric and I just put numbers in this field to sort values the way I want. This allows me to sort even if the sort order needs to be non-alphabetical.

Good luck,
GJ
 
Thanks very much RedLion and GunJack. The <cfif fileExists(&quot;d:/ worked well.

As for the second issue, unfortunately it is still there, as it is not possible for me to either change the type to integer or to put a zero in the front. But, thanks for your help.
 
I (unfortunately) use MS Access :(

Try using this SQL query to sort your data.

SELECT *
FROM TABLE1
ORDER BY INT(MID(field1, 2))

It sorts by the value &quot;eliminating the 'n' and changing it to a number&quot;. The actual content of your data stays intact.
 
Thanks AbeMeister. I could not get it to work. I must be doing something silly.

I have an additional problem. The prefix can vary in size. It can be N or SW or NE etc. Can this be resolved ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top