Author |
Topic |
GauravBhabu
Advanced Member
4288 Posts |
Posted - 20 November 2001 : 00:39:29
|
One way is to do the split and do for next.
The other is find the position of FirstComma and last Comma and then
1. Compare the member ID enclosed in commas starting from the postion of firstcomma-1 Instr(firstcomma-1,Topic_whoviewedView,"'" & memberid & "'") 2. Compare the memberID with comma in the beginning starting from the position of lastcomma - Instr(lastcomma,Topic_whoviewedView,memberid) 3. Compare the memberID starting at position of firstcomma - InstrRev(
GauravBhabu There is only one miracle...That is LIFE! | It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Edited by - GauravBhabu on 20 November 2001 00:48:07
Edited by - GauravBhabu on 20 November 2001 00:53:19 |
|
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 20 November 2001 : 01:11:01
|
Checkout this, Hopefully this will be Okay.
***Removed Bad Code to avoid Confusion
GauravBhabu There is only one miracle...That is LIFE! | It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Edited by - GauravBhabu on 20 November 2001 06:35:27 |
|
|
suhern
Junior Member
186 Posts |
Posted - 20 November 2001 : 01:59:46
|
quote:
Checkout this, Hopefully this will be Okay.
if IsNull(Topic_WhoViewed) or Topic_WhoViewed = "" or Topic_WhoViewed = "0" or Len(Trim(Topic_WhoViewed)) = 0 then UpdateTview = MemberID DOUpDate = true else Firstcomma = Instr(1,Topic_WhoViewed, ",",1) LastComma = InstrRev(Topic_WhoViewed,",",-1,1) if FirstComma = 0 then FirstComma = 1 if LastComma = 0 then LastComma = FirstComma If Instr(FirstComma,Topic_WhoViewed, "," & MemberID & ",",1) > 0 or _ Instr(LastComma,Topic_WhoViewed, MemberID,1) > 0 or _ InstrRev(Topic_WhoViewed, MemberID,FirstComma,1) > 0 or _ (len(Topic_WhoViewed) + len(MemberID) = 255) or _ (len(Topic_WhoViewed) + len(MemberID) > 255) then DOUpDate = false else DOUpDate = true UpdateTview = Topic_WhoViewed & "," & MemberID end if end if
GauravBhabu There is only one miracle...That is LIFE! | It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Edited by - GauravBhabu on 20 November 2001 01:12:42
Sorry I tried and it is still not working
|
|
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 20 November 2001 : 02:23:23
|
Okay This will work
***Removed Bad Code to avoid Confusion
GauravBhabu There is only one miracle...That is LIFE! | It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Edited by - GauravBhabu on 20 November 2001 06:35:59 |
|
|
suhern
Junior Member
186 Posts |
Posted - 20 November 2001 : 03:08:11
|
quote:
Okay This will work
if IsNull(Topic_WhoViewed) or Topic_WhoViewed = "" or Topic_WhoViewed = "0" or Len(Trim(Topic_WhoViewed)) = 0 then UpdateTview = MemberID DOUpDate = true else Firstcomma = Instr(1,Topic_WhoViewed, ",",1) LastComma = InstrRev(Topic_WhoViewed,",",-1,1) if FirstComma = 0 then FirstComma = 1 if LastComma = 0 then LastComma = FirstComma If Instr(FirstComma,Topic_WhoViewed, "," & MemberID & ",",1) > 0 or _ Instr(LastComma,Topic_WhoViewed,"," & MemberID,1) > 0 or _ InstrRev(Topic_WhoViewed,MemberID & "," ,FirstComma,1) > 0 or _ (Instr(Topic_WhoViewed,Member_ID) > 0 And Instr(Topic_WhoViewed,",")= 0) or _ (len(Topic_WhoViewed) + len(MemberID) = 255) or _ (len(Topic_WhoViewed) + len(MemberID) > 255) then DOUpDate = false else DOUpDate = true UpdateTview = Topic_WhoViewed & "," & MemberID end if end if
GauravBhabu There is only one miracle...That is LIFE! | It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Edited by - GauravBhabu on 20 November 2001 02:30:30
Edited by - GauravBhabu on 20 November 2001 02:37:38
I afraid it is still not working, my id = 1. there is one topic that refuses to capture me.
|
|
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 20 November 2001 : 03:13:34
|
I tested it works Okay. Make sure the following three statements are exactly as below
Instr(LastComma,Topic_WhoViewed,"," & MemberID,1) > 0 or _ InstrRev(Topic_WhoViewed,MemberID & "," ,FirstComma,1) > 0 or _ (Instr(Topic_WhoViewed,Member_ID) > 0 And Instr(Topic_WhoViewed,",")= 0) or _
Okay, it will still fail under certain circumstances. I know where.
GauravBhabu There is only one miracle...That is LIFE! | It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Edited by - GauravBhabu on 20 November 2001 03:14:02
Edited by - GauravBhabu on 20 November 2001 03:19:03 |
|
|
Da_Stimulator
DEV Team Forum Moderator
USA
3373 Posts |
Posted - 20 November 2001 : 03:23:07
|
Wow what I miss when Im busy :)
Thx GauravBhabu - I updated the zip with your changes.
---- -Eric | Mod Resource | Test Area "A program is a device used to convert data into error messages." http://phpscriptcenter.com -Quality PHP Scripts |
|
|
suhern
Junior Member
186 Posts |
Posted - 20 November 2001 : 03:31:05
|
It is still not working this is the code and thanks for all the help.
quote:
'--------------- TOPIC AND REPLY VIEW if MemberID = 0 or IsNull(MemberID) then 'dont update anything else strsql = "SELECT " & strActivePrefix & "TOPICS.T_WHOVIEWED FROM " & strActivePrefix & "TOPICS WHERE " strsql = strsql & strActivePrefix & "TOPICS.TOPIC_ID=" & Topic_ID set tviewRS = Server.CreateObject("ADODB.RecordSet") tviewRS.open strsql, my_conn, 3 Topic_WhoViewed = tviewRS("T_WHOVIEWED") tviewRS.close set tviewRS = nothing
if IsNull(Topic_WhoViewed) or Topic_WhoViewed = "" or Topic_WhoViewed = "0" or Len(Trim(Topic_WhoViewed)) = 0 then UpdateTview = MemberID DOUpDate = true else Firstcomma = Instr(1,Topic_WhoViewed, ",",1) LastComma = InstrRev(Topic_WhoViewed,",",-1,1) if FirstComma = 0 then FirstComma = 1 if LastComma = 0 then LastComma = FirstComma If Instr(LastComma,Topic_WhoViewed,"," & MemberID,1) > 0 or _ InstrRev(Topic_WhoViewed,MemberID & "," ,FirstComma,1) > 0 or _ (Instr(Topic_WhoViewed,Member_ID) > 0 And Instr(Topic_WhoViewed,",")= 0) or _ (len(Topic_WhoViewed) + len(MemberID) = 255) or _ (len(Topic_WhoViewed) + len(MemberID) > 255) then DOUpDate = false else DOUpDate = true UpdateTview = Topic_WhoViewed & "," & MemberID end if end if if DOUpdate = true then strsql = "UPDATE " & strActivePrefix & "TOPICS " strsql = strsql & "SET " & strActivePrefix & "TOPICS.T_WHOVIEWED = '" & UpdateTview & "' WHERE " strsql = strsql & strActivePrefix & "TOPICS.TOPIC_ID = " & Topic_ID my_conn.execute(strsql) end if end if '--------------- END TOPIC AND REPLY VIEW
|
|
|
suhern
Junior Member
186 Posts |
Posted - 20 November 2001 : 03:34:19
|
Just to add there this id =131 in one topic and it is stopping me from getting capture.
|
|
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 20 November 2001 : 03:40:08
|
quote:
Just to add there this id =131 in one topic and it is stopping me from getting capture.
Yes, I also noticed. Here is the fix.
***Removed Bad Code to avoid Confusion
GauravBhabu There is only one miracle...That is LIFE! | It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Edited by - GauravBhabu on 20 November 2001 06:36:53 |
|
|
Classicmotorcycling
Development Team Leader
Australia
2084 Posts |
|
Da_Stimulator
DEV Team Forum Moderator
USA
3373 Posts |
Posted - 20 November 2001 : 03:59:00
|
Thx CM - you may want to update it to GauravBhabu code though -
Zip is updated.
---- -Eric | Mod Resource | Test Area "A program is a device used to convert data into error messages." http://phpscriptcenter.com -Quality PHP Scripts |
|
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 20 November 2001 : 04:17:10
|
stim, the code in my last post is a good fix. Just a minor issue in one condition but that is taken care in the other condition
GauravBhabu There is only one miracle...That is LIFE! | It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying. |
|
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 20 November 2001 : 06:41:12
|
Finally A Good Fix. Hopefully without any Issues.
'--------------- TOPIC AND REPLY VIEW if MemberID = 0 or IsNull(MemberID) or MemberID < 0 then 'dont update anything else strsql = "SELECT " & strActivePrefix & "TOPICS.T_WHOVIEWED FROM " & strActivePrefix & "TOPICS WHERE " strsql = strsql & strActivePrefix & "TOPICS.TOPIC_ID=" & Topic_ID set tviewRS = Server.CreateObject("ADODB.RecordSet") tviewRS.open strsql, my_conn, 3 Topic_WhoViewed = tviewRS("T_WHOVIEWED") tviewRS.close set tviewRS = nothing if IsNull(Topic_WhoViewed) or Topic_WhoViewed = "" or Topic_WhoViewed = "0" or Len(Trim(Topic_WhoViewed)) = 0 then UpdateTview = MemberID DOUpDate = true else DoUpDate = True LenWhoViewed = len(Topic_WhoViewed) Firstcomma = Instr(1,Topic_WhoViewed, ",",1) LastComma = InstrRev(Topic_WhoViewed,",",-1,1) If FirstComma = 0 then if (LenWhoViewed = len(MemberID) and Instr(Topic_WhoViewed,MemberID) > 0) then 'MatchFound DOUpDate = false end if end if if (FirstComma > 0 and LastComma >= FirstComma and DoUpdate = true) then If Instr(FirstComma,Topic_WhoViewed, "," & MemberID & ",",1) > 0 then 'MatchFound DOUpDate = false end if if (Instr(LastComma,Topic_WhoViewed, "," & MemberID ,1) > 0 and _ LenWhoViewed = LastComma + len(MemberID)) then 'MatchFound DOUpDate = false end if if (InstrRev(Topic_WhoViewed, MemberID & "," ,FirstComma,1) > 0 and _ len(left(Topic_WhoViewed,FirstComma-1)) = len(MemberID)) then 'MatchFound DoUpDate = false end if end if if DoUpdate = True then if (len(Topic_WhoViewed) + len(MemberID) = 255) or _ (len(Topic_WhoViewed) + len(MemberID) > 255) then 'Max Limit DoUpDate = false end if end if if DoUpDate = True then UpdateTview = Topic_WhoViewed & "," & MemberID end if end if if DOUpdate = true then strsql = "UPDATE " & strActivePrefix & "TOPICS " strsql = strsql & "SET " & strActivePrefix & "TOPICS.T_WHOVIEWED = '" & UpdateTview & "' WHERE " strsql = strsql & strActivePrefix & "TOPICS.TOPIC_ID = " & Topic_ID my_conn.execute(strsql) end if end if '--------------- END TOPIC AND REPLY VIEW
GauravBhabu There is only one miracle...That is LIFE! | It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Edited by - GauravBhabu on 20 November 2001 16:15:27 |
|
|
Da_Stimulator
DEV Team Forum Moderator
USA
3373 Posts |
|
Topic |
|
|
|