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

  • Home
  • SEARCH
  • 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 7925107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:08:09+00:00 2026-06-03T18:08:09+00:00

I’m having a problem with retrieving information from a MySQL Table with PHP. I

  • 0

I’m having a problem with retrieving information from a MySQL Table with PHP.
I Have the following table in the MySQL database:

id | pigeon_sn | mother_sn | father_sn

id – represents the unique ID;
pigeon_sn – represents the pigeon ring serial number
mother_sn – represents the mother of the pigeon – ring serial number
father_sn – represents the father of the pigeon – ring serial number

I’d like to retrieve from the database the information as a pedigree like file.
This means I need to retrieve the information as follows:

I insert the serial number of the ring of a pigeon.
– it gives me the serial number of the mother and father ring.
– then, for each new serial number ( mother and father ) retrieves the father corresponding to the serial no obtained before, and the mother corresponding to the serial no before.
– the algorithm goes on for a given number of iterations ( For example 3 will retrieve 3 generations of pigeons by their mother and father serial number ).

I belive that this can be done recursively or just by an for algorithm that goes for a given number of iterations. For every pigeon ( pigeon is represented by the serial number obtained from the pigeon before ) the algorithm will create an associative array with all the information on that row table.

Thank you in advice.

  • 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-06-03T18:08:10+00:00Added an answer on June 3, 2026 at 6:08 pm

    Got this working up if somebody needs it:

    First you get the first pigeon and their parents:

    $pedigree[0] = $this->fetchRow(“pigeon_sn='{$sn}'”);

    $pedigree[1][] = $this->fetchRow(“pigeon_sn='{$pedigree[0][‘SN_m’]}'”);

    $pedigree[1][] = $this->fetchRow(“pigeon_sn='{$pedigree[0][‘SN_t’]}'”);

    and after that you will go like this:

        public function recurseDB($last_level,&$result,$level=1,$limit=2){
            //Check if las level was an array
            if($level <= $limit){
                if(is_array($last_level)){   
                    foreach($last_level as $array){
                        $result[$level+1][] = $this->fetchRow("pigeon_SN='{$array['SN_m']}'");
                        $result[$level+1][] = $this->fetchRow("pigeon_SN='{$array['SN_t']}'");
                    }
                    $this->recurseDB($result[$level+1],$result,$level+1,$limit);
                }
                else
                {
                    $result[$level][] = $this->fetchRow("pigeon_SN='{$last_level['SN_m']}'");
                    $result[$level][] = $this->fetchRow("pigeon_SN='{$last_level['SN_t']}'");
                }
            }
        } 
    

    for the recursive funciton.

    • 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&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from
I have a text area in my form which accepts all possible characters from
I have a reasonable size flat file database of text documents mostly saved in
I have a bunch of posts stored in text files formatted in yaml/textile (from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have just tried to save a simple *.rtf file with some websites and

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.