Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / July 2006



Tip: Looking for answers? Try searching our database.

removing zero with loop

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
macca242424 - 29 Jul 2006 05:51 GMT
Hello i have a Insert query which loops through my form from the previous page,
what i need to do is if the PlayerPhone starts with "0" to remove it, i have
tried the code below but i am having probllems can someone help

<cfloop index="currRow" from="#form.startRow#" to="#form.dispRows#">
    <cfif IsDefined("form.ID_#currRow#")>
        <cfset ID = Evaluate("form.ID_" & currRow)>
           
<cfif left("form.PlayerPhone_#currRow#",1) EQ "0">
<cfset PhoneNo=removeChars(replace("form.PlayerPhone_#currRow#", " ", "",
"all"),1,1)>
</cfif>
       
<cfquery name="INSERT" datasource="iluvcricket">
INSERT INTO sms_players_table
(PlayerFirstName, PlayerSurname, PlayerPhone, ClubID)
VALUES
('#form["PlayerFirstName_#currRow#"]#', '#form["PlayerSurname_#currRow#"]#',
#PhoneNo#, #form.ClubID#)
</cfquery>
<cfelse>
        <cfbreak>
    </cfif>
</cfloop>
Dan Bracuk - 29 Jul 2006 22:17 GMT
The quotes around your variable in your cfif tag might be messing you up.  Also, if the number does not start with a 0, your phoneno variable won't be defined.
macca242424 - 29 Jul 2006 23:41 GMT
ok  thanks i have done that and put a cfelse in, but now i get an error for the
two # in line 1

<cfif left(form.PlayerPhone_#currRow#,1) EQ "0">
<cfset PhoneNo=removeChars(replace("form.PlayerPhone_#currRow#", " ", "",
"all"),1,1)>
<cfelse>
<cfset PhoneNo=("form.PlayerPhone_#currRow#")>
</cfif>
Dan Bracuk - 29 Jul 2006 23:53 GMT
I forget the exact syntax you need, but it might involve square brackets.
macca242424 - 30 Jul 2006 03:14 GMT
ok i have played around but still cant get it right, can anyone help
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.