Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6599985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:33:48+00:00 2026-05-25T18:33:48+00:00

I’m not sure this is even possible, but I would really like to be

  • 0

I’m not sure this is even possible, but I would really like to be sure in order to create the most efficient code…
I need to build a query that works like an affiliate –
when a user signs in, I need to see if someone invited him, or if he got there alone (basic URL param). If he was invited, I need to give him X points. If the inviter was invited by someone, I need to give him 1/2X points, and if he was also invited, I need to give his inviter 1/4 points. I need this to be endless until the parent of all has no more “invited_by” values (null/0)…

I did this with a php (while x), a counter to calculate the amount of points – 1/(X sqr $i), but i’m not happy because it takes me a select and update query each time…

I’m using php and mysql.
Is there someone who can think of a better way to do this?
Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:33:48+00:00Added an answer on May 25, 2026 at 6:33 pm

    I think that you will need an iterative solution. I don’t see any hierarchical query operators in the MySQL manual that might help you out (but that isn’t quite the same as saying there aren’t any; my eyesight isn’t perfect). You could perform it in a stored procedure, which would reduce the cost of the operation (less data transferred between database server and client).

    Also, the X/2, X/4, X/8, sequence isn’t captured by the expressions 1/2X or 1/(X sqr $i); I assume that there was no intent to give the invitrr a fraction of a point whereas the inviter’s inviter gets X/4 points?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I would like to count the length of a string with PHP. The string
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I have some data like this: 1 2 3 4 5 9 2 6
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.