Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
murpg #1
Problem with function ListGetAt
I have written the code for a DB driven image viewer. It is pretty simple. I
am having a problem with my navagtion going to the previous and next links.
The times when I have a problem is when I am on the number 2 in my list I don't
see the previous link to get me to number 1. The other time when I see a
problem is when I try to start on the number 1 in the list I get this error
message.
Error Occurred While Processing Request
Invalid list index 0.
In function ListGetAt(list, index [, delimiters]), the value of index, 0, is
not a valid as the first argument (this list has 10 elements). Valid indexes
are in the range 1 through the number of elements in the list.
The Error Occurred in C:\CFusionMX\wwwroot\hunter\image_display.cfm: line 36
34 : <cfset nextImageID = ListGetAt(ImageIDList, nextPos)>
35 : <cfset prevPos = Listfind(ImageIDList, url.ID, ",") - 1>
36 : <cfset prevImageID = ListGetAt(ImageIDList, prevPos)>
37 :
38 : <table width="100%" border="0" cellpadding="0" cellspacing="0"
bgcolor="#9999CC">
Can someone please help.
<!--- Get All Pictures --->
<cfquery name="qGetPictures" datasource="hmddb">
SELECT *
FROM Test
</cfquery>
<!--- Query the original query to grab 1 Picture --->
<cfquery name="qGetSinglePic" dbtype="query">
SELECT *
FROM qGetPictures
WHERE ID = #URL.ID#
</cfquery>
<!--- mechanism to grab Image IDS --->
<cfset ImageIDList="">
<!--- Make List of the Picture IDs --->
<cfloop query="qGetPictures">
<cfset ImageIDList=#ListAppend(ImageIDList, qGetPictures.ID)#>
</cfloop>
<!--- Get the Locations of the ID in the List --->
<!--- Set the IDs for the next and prev buttons --->
<cfset nextPos = Listfind(ImageIDList, url.ID, ",") + 1>
<cfset nextImageID = ListGetAt(ImageIDList, nextPos)>
<cfset prevPos = Listfind(ImageIDList, url.ID, ",") - 1>
<cfset prevImageID = ListGetAt(ImageIDList, prevPos)>
<table width="100%" border="0" cellpadding="0" cellspacing="0"
bgcolor="#9999CC">
<tr>
<cfoutput query="qGetSinglePic">
<td align="center"><img src=Portfolio/images/5/#imageName#></td>
</cfoutput>
</tr>
<tr>
<td align="center"><cfoutput><cfif ListFirst(ImageIDList , ",") NEQ
prevImageID> <a href="image_display.cfm?ID=#prevImageID#">Prev image</a></cfif>
| <cfif ListLast(ImageIDList , ",") NEQ nextImageID><a
href="image_display.cfm?ID=#nextImageID#">Next image</a></cfif></cfoutput></td>
</tr>
</table>
murpg Guest
-
ListGetAt in CFQUERY
I have a database of computer components that helps drive a custom system builder. I have 1 price field that has a list of prices delimited with an... -
Problem using GD function
Hi all, I've got a Red Hat 9 system with gd-1.8.4 installed and php-4.3.4 working on apache 2.0.48. When I try to use the imagecreatefromjpeg... -
problem with db function php
hi echo '<table>'; $requete = mysql_query("SELECT liv_nolivre, sec_nosection, liv_commentaire, liv_titre FROM livre"); if (... -
Function Problem
Hi, I have the following function below used to make a couple of calculations however as soon as I have two records the function calculation is... -
[PHP] problem with imagettfbbox() function
I installed PHP 4.3.3 with default values. When I moved my sites, who use imagettfbbox() function, I received message -Fatal error: Call to... -
OldCFer #2
Re: Problem with function ListGetAt
The following is certain to cause errors at some point:
<cfset prevPos = Listfind(ImageIDList, url.ID, ",") - 1>
because when the listfind() returns 1 then prevPos will be 0, and
as you can see it causes an error when you use ListGetAt() with a zero
position.
OldCFer Guest
-
murpg #3
Re: Problem with function ListGetAt
I understand what's causing this, but how do I fix it? I can't think the logic all the way through.
murpg Guest
-
MikerRoo #4
Re: Problem with function ListGetAt
Without writing the code for you, here's how to fix it:
You need to add <cfif> logic...
Page 1 does not have a "previous" link and the last page does not have a
"next" link.
Such logic would eliminate the listindex problems you are seeing.
-- MikeR
MikerRoo Guest



Reply With Quote

