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