Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Unwanted links when using ORDER BY

Guest
Jan 28, 2013 Jan 28, 2013

I have a search results page that has been giving me a headache for a few weeks now lol. I have the following SQL to filter what the user is looking for with the search engine. Everything works fine UNTIL i sort the results by province. When i do so i get sereval unwanted image links. For example. If i get 7 results when i sort by ON (ontario) and 1 out of the 7 pets has an image which gives the word "image" repeating 7x based on the sort result and only 1 of those links actually work. Not sure why the others are appearing. I know it's because of the ORDER BY i have in the SQL, because when i remove the order by it works prefectly. I searched all over to find someone else with somewhat of a similar problem, but no go. Looked at my sql reference book and still nothing. Now sure whats wrong. Hope someone can see something i can't.

------ SQL for search engine -------

  <cfquery name="qSearch" datasource="#APPLICATION.dataSource#">

  SELECT PetID, PetName, PetType, PetStatus, PetGender, Province, City, MyPetID, PostDate, PetBreed, ImageName

  FROM PetFind

  WHERE 0=0

  AND (PetName = '#Search#' OR MyPetID LIKE '%#Search#%')

<cfif IsDefined('URL.Province')>

  AND Province = <cfqueryparam value="#URL.Province#" cfsqltype="cf_sql_varchar">

  ORDER BY City

  ASC

</cfif>

  </cfquery>

------ Image link (popUp) ------

        <a href="javascript:popImage('../pimages/#URLEncodedFormat(qSearch.ImageName)#.jpg','Picture of #qSearch.PetName#')" onLoad="window.location.href=window.location.href">
          Image
        </a>
410
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 28, 2013 Jan 28, 2013

What's the code you're using for looping over the recordset and outputting the image links?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 28, 2013 Jan 28, 2013
LATEST

I found the problem because you asked about the outputting. I had 2 cfoutputs when i only needed the 1. So thanks for the reply it helped alot and saved me future headaches on this issue. lol

Cheers

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources