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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:52:58+00:00 2026-06-07T10:52:58+00:00

I have made 3 tables in a DB with a many to many relationship.

  • 0

I have made 3 tables in a DB with a many to many relationship. for variable $refernece_keys in my DB should return all of the related fields in the DB – but it is only returning the first assigned and ignoring the others.

e.g. page1 should return keys_href: id's 1, 2, 3, 4, 8, 10, 15 - however it only returns id:1
page2 should return keys href: id's 3, 4, 5, 7, 8, 11 - however it only returns id:3

Is there something wrong with my ARRAY?

$SQL = 
   "SELECT  * FROM learn_more AS lm 

LEFT JOIN  learn_more_to_reference_key AS lmtrk 
        ON  lm.id = lmtrk.learn_more_id 

LEFT JOIN  reference_keys AS rk 
        ON  rk.keys_id = lmtrk.reference_key_id

     WHERE  lm.page_title = '$this_page'";

$result = mysql_query($SQL) or die(mysql_error()); 

 while ($db_field = mysql_fetch_array($result))
{   
        $id                =     $db_field['id'];
        $main_title        =     $db_field['main_title'];
        $main_content     =     $db_field['main_content'];
        $reference_keys   =     $db_field['keys_href']; 
        $sub_title        =     $db_field['sub_title'];
        $sub_content      =     $db_field['sub_content'];
}

————————————————>EDIT

My PHP view page is a template

<div id="content">  
<div class="section_frame">


<div class="section_title">
<?php echo $main_title; ?>
</div>

<div class="section_content">
<?php echo $main_content; ?>
</div>


<div class="section_content_ref">
<span class="hl_reference"><u>key references:</u></span> 
<?php echo $reference_keys; ?>
</div>

<div class="sub_section_title">
<?php echo $sub_title; ?>
</div>

<div class="sub_section_content">
<?php echo $sub_content; ?>
</div>

so basically i just want my values to echo out..

  • 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-07T10:53:00+00:00Added an answer on June 7, 2026 at 10:53 am

    Ah, my first thought would be that since your while loop runs over all the records, after it is finished only the last record is available… except you are only seeing the first one. if you were to add echo $id inside the while loop, do all the IDs get printed? Also, if you have some more code to complete the example that would help.

    $items = array();
    while ($db_field = mysql_fetch_array($result))
    {   
        $id                =     $db_field['id'];
        $main_title        =     $db_field['main_title'];
        $main_content     =     $db_field['main_content'];
        $reference_keys   =     $db_field['keys_href']; 
        $sub_title        =     $db_field['sub_title'];
        $sub_content      =     $db_field['sub_content'];
        $items[$id] = array($main_title, $main_content, $reference_keys, $sub_title, $sub_content);
    }
    

    The above would create an array where the id of each record points to the record information. Is that along the lines of what you are going for?

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

Sidebar

Related Questions

i have a database with 3 tables in a many-to-many relationship. one is the
I have a many-to-many relationship between 2 tables that I define with a join
i have made columns in some of the tables encrypted in sql server 2008.
I have a problem with my self-made search page. There is 2 tables: **name
I have a table of many movies all with associated with different Director IDs,
I have these tables Genre and Songs . There is obviously many to many
I have made a table row draggable with jQuery. It works as expected (mostly)
I have made a registration table reg1 and stored the values for every registered
I have made a dump of my database in which one table is pretty
I have a MySQL database and with a php function i made a table

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.