Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
Paulie579 #1
Need help with an array
I have this textarea in form that allows users to enter ip(s) to search the
database.
First the IP(s) has to go through this script that will insert 0s if the user
didn't not put zero in. (ie., 192.168.1.1 after script 192.168.001.001).
They search the database for the all IP(s) entered.
I have it working in an ASP page, but I need to do this in CF.
Here is what I have in ASP:
<%
If (Request.Form("IPVAL") <> "") Then
IPArray = Split(Request.Form("IPVAL"),",")
For X = 0 To UBound(IPArray)
IP1 = "000"
IP2 = "000"
IP3 = "000"
IP4 = "000"
ProcessingIP = IPArray(X)
' Make sure there is a number to convert in the upper part
IP1 = Mid(ProcessingIP, InStr(ProcessingIP, ".") + 1)
IP2 = Mid(IP1, InStr(IP1, ".") + 1)
IP3 = Trim(Mid(IP2, InStr(IP2, ".") + 1))
IP4 = Right("00" + IP3, 3)
IP3 = Right("00" + Mid(IP2, 1, InStr(IP2, ".") - 1), 3)
IP2 = Right("00" + Mid(IP1, 1, InStr(IP1, ".") - 1), 3)
IP1 = Left(ProcessingIP, InStr(ProcessingIP, ".") - 1)
IPArray(X) = IP1 + "." + IP2 + "." + IP3 + "." + IP4
Next
IPList = Join(IPArray,",")
End If
%>
This is the script to fill in the zero.
Now I also do not know how to write a where clause to search through a list?
This is what I have in ASP
WHERE IP IN ('" & Replace(IPList,",","','") & "')
Thank you for the Help!!!
Paulie579 Guest
-
Converting an XML Array to a multi-level array
I have an array assigned to a data grid such as: private var myIngredients:Array = new Array( <item ln1="Plain" sn="plain" ln2="(3 cups)... -
[newbie]saving and reading array of associative array
i'm looking for examples of saving to file and reading back an array of associative array, in a ruby like way. saying i have something like : ... -
array data matches but array created in loop doesn't work
I have the exact same data in two arrays, but only the array created like so will work: $spaw_imglibs = array( array( 'value' =>... -
#24897 [Com]: array_multisort() will reindex the array but not if array length is 1
ID: 24897 Comment by: franklin_se at hotmail dot com Reported By: chro at sokrates dot uio dot no Status: ... -
#24897 [Opn->Asn]: array_multisort() will reindex the array but not if array length is 1
ID: 24897 Updated by: sniper@php.net Reported By: chro at sokrates dot uio dot no -Status: Open +Status: ... -
CFDEBUG #2
Re: Need help with an array
One way to do this is
Here temp has a list of IPs separated by commas.
<cfset newip=ArrayNew(1)>
<cfset rownum=1>
<cfoutput>
<cfloop list="#temp#" delimiters="," index="ip">
<cfloop list="#ip#" delimiters="." index="i">
<cfif len(i) lt 3>
<cfset ip=listsetat(ip,listfind(ip,i,'.'),"00#i#",'.')>
</cfif>
</cfloop>
<cfset newip[rownum]=ip>
<cfset rownum=rownum+1>
</cfloop>
#ArrayToList(newip)#
</cfoutput>
CFDEBUG Guest
-
Paulie579 #3
Re: Need help with an array
thanks for the help
it worked just the way i needed it too
Paulie579 Guest



Reply With Quote

