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 6832315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:50:38+00:00 2026-05-26T22:50:38+00:00

I’m trying to actually loop a function with a different function parameter each time

  • 0

I’m trying to actually loop a function with a different function parameter each time which is obtained by the function itself;

Im using a variable $login_name as function parameter which was submitted by a form. So I want to change this parameter by the function itself. absurd? is there any alternative?

Here’s my function

$login_name = "U00001";
while (!isset($end)) {
    function getcount($login_name) {
        $get_node = mysql_query("SELECT * FROM b_userbase WHERE login_name='$login_name'");
        while ($row_node = mysql_fetch_array($get_node)) {
            $node = $row_node["user_node"];
            $placement = $row_node["user_placement"];
        }
        $current_count = mysql_query("SELECT * FROM f_user_matching WHERE u_m_mem='$placement'");
        while ($get_count = mysql_fetch_array($current_count)) {
            $get_left_current = $get_count["u_m_left_current"];
            $get_left_total = $get_count["u_m_left_total"];
            $get_right_current = $get_count["u_m_right_current"];
            $get_right_total = $get_count["u_m_right_total"];
            $update_left_current = $get_left_current + 1;
            $update_right_current = $get_right_current + 1;
            $update_left_total = $get_left_total + 1;
            $update_right_total = $get_right_total + 1;
        }
        if ($node == "L") {
            $increase_qry = mysql_query("UPDATE f_user_matching 
                                            SET u_m_left_current= '{$update_left_current}',
                                                u_m_left_total ='{$update_left_total}'
                                            WHERE u_m_mem ='{$placement}' ");
        }
        if ($node == "R") {
            $increase_qry = mysql_query("UPDATE f_user_matching 
                                            SET u_m_right_current= '{$update_right_current}',
                                                u_m_right_total ='{$update_right_total}'
                                            WHERE u_m_mem ='{$placement}' ");
        }
        $login_name = $placement;
        if ($login_name == "IM000001") {
            $end = 1;
        } else {
            $login_name = $placement;
        }
        global $login_name;
    }
    $count = getcount($login_name);
}

Where is the problem?

  • 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-26T22:50:39+00:00Added an answer on May 26, 2026 at 10:50 pm

    I dont understand what you ar doing, so you might be trying to do something different that I do not know about, but if what you need is an recursive function then this is not the way. You dont define the function inside a while-loop, the function should be defined as a normal function, but in can call itself whit a different result.

    This is how your function would be as recursive.
    This is not tested code

        <?php
    
     $login_name = "U00001";
     $count = getcount($login_name);
    
     function getcount($login_name) {
            $get_node = mysql_query("SELECT * FROM b_userbase WHERE login_name='$login_name'");
            while ($row_node = mysql_fetch_array($get_node)) {
                $node = $row_node["user_node"];
                $placement = $row_node["user_placement"];
            }
            $current_count = mysql_query("SELECT * FROM f_user_matching WHERE u_m_mem='$placement'");
            while ($get_count = mysql_fetch_array($current_count)) {
                $get_left_current = $get_count["u_m_left_current"];
                $get_left_total = $get_count["u_m_left_total"];
                $get_right_current = $get_count["u_m_right_current"];
                $get_right_total = $get_count["u_m_right_total"];
                $update_left_current = $get_left_current + 1;
                $update_right_current = $get_right_current + 1;
                $update_left_total = $get_left_total + 1;
                $update_right_total = $get_right_total + 1;
            }
            if ($node == "L") {
                $increase_qry = mysql_query("UPDATE f_user_matching 
                                                SET u_m_left_current= '{$update_left_current}',
                                                    u_m_left_total ='{$update_left_total}'
                                                WHERE u_m_mem ='{$placement}' ");
            }
            if ($node == "R") {
                $increase_qry = mysql_query("UPDATE f_user_matching 
                                                SET u_m_right_current= '{$update_right_current}',
                                                    u_m_right_total ='{$update_right_total}'
                                                WHERE u_m_mem ='{$placement}' ");
            }
            $login_name = $placement;
            if ($login_name != "IM000001") {
                $login_name = $placement;
                $count = getcount($login_name);
            }
            global $login_name; // Dont know why you want this one?
    
        }
    
        ?>
    

    Dont know why you have *global $login_name;* at the end. Do you want the function to return something or just perform the UPDATE in the database?

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to loop through a bunch of documents I have to put
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.