[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.8

Question for mkishline

Asked by dizzot in ColdFusion Application Server

Tags: checked, listfind, valuelist

For some reason things aren't working, here is the code I am using, for some reason the results are really weird. I am wondering about the <cfset user = id of person> why is currentfriendlist and total friend list set to this as well. What I am seeing happen is the "i" is equaling the user id of the person. Our table is set up as such,

Id  Userid  Friendid
1      1           2
2      2           1
3      3           2
4      2           3
5      10         1
6       1          10

If I set the lookingfor to 10, as it is in this instance, and user to 3 I get 10 was found at 1,
If I switch those, 3 looking for, 10 user then I get "Not in your network"
Neither of which are correct,
Please Help

<!--- Create a query that contains every person in your database --->
<cfquery name="everyone" datasource="Dizzot">
     SELECT Id,UserId,FriendId
     FROM Friends.Friendslist
      
</cfquery>

<!--- This function will return a comma-delimited list of the ID numbers of people who are friends with #currentUser# --->
<cffunction name="getFriends" access="private" output="false" returntype="string">
     <!--- The id of the user whose friends we're searching for --->
     <cfargument name="currentUser" type="numeric" required="yes" />
     <!--- All of the friends who have been found so far --->
     <cfargument name="currentFriends" type="string" required="yes" />

     <cfquery name="friends" dbtype="query">
          SELECT UserId
          FROM everyone
          WHERE FriendId = <cfqueryparam value="#currentUser#" CFSQLType="CF_SQL_INTEGER" />
          <!--- Exclude everyone who has already been found as a friend --->
          <cfloop index="i" list="#currentFriends#">
          AND UserID <> <cfqueryparam value="#i#" CFSQLType="CF_SQL_INTEGER" />
          </cfloop>
     </cfquery>

     <!--- Return a comma-delimited list of the ID numbers of the friends found for this person --->
     <cfreturn ValueList(friends.UserID) />
</cffunction>

<cfset lookingfor = "10" />

<cfset user = "3" />
<cfset currentfriendlist = user />
<cfset totalfriendList = user />
<cfset found = false />

<!--- Make sure we only do this 6 times --->
<cfloop index="i" from="1" to="6">
     <!--- Perform once for every friend at this level --->
     <cfloop index="j" list="#currentfriendlist#">
          <cfset nextlevelfriendlist = "" />
          <!--- Get the friends of this person, excluding any friends who were previously found --->
          <cfset friends = getFriends(j,totalfriendlist) />
          <!--- If the person we are looking for is in this list, notify the user and break out --->
          <cfif ListFind(friends,lookingfor) GT 0>
               <cfset found = true />
               <cfoutput>#lookingfor# was found at level #i#</cfoutput><cfbreak />
          <!--- If we still haven't found the person --->
          <cfelse>
               <!--- add all the friends that were found on this level to be checked on the iteration --->
               <cfset nextlevelfriendlist = ListAppend(nextlevelfriendlist,friends) />
               <!--- add all the friends that were found on this level to be excluded from future checks --->
               <cfset totalfriendlist = ListAppend(totalfriendlist,friends) />
          </cfif>
     </cfloop>
     <!--- Set the list of friends found on this level to be searched the next time around --->
     <cfset currentfriendlist = nextlevelfriendlist />
</cfloop>
<cfif ListFind(friends,lookingfor) EQ 0>
Not in your Network
</cfif>
[+][-]01/25/06 09:11 PM, ID: 15792810Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/25/06 09:13 PM, ID: 15792816Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/26/06 07:06 AM, ID: 15795667Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: ColdFusion Application Server
Tags: checked, listfind, valuelist
Sign Up Now!
Solution Provided By: mkishline
Participating Experts: 2
Solution Grade: A
 
[+][-]01/26/06 07:08 AM, ID: 15795685Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/26/06 08:36 AM, ID: 15796653Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81