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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:15:31+00:00 2026-05-31T13:15:31+00:00

I have 2 tables, the unique id’s in each table are the same in

  • 0

I have 2 tables, the unique id’s in each table are the same in both tables.
How do I go about joining the data from both tables together in php?

When I normally pull data I do it like this:

    $get_board_array = mysql_query("SELECT * FROM posts WHERE user_id_to = '$id' ");
      while($posts = mysql_fetch_array($get_board_array))
        {
          $post_id = $get_post['post_id']; 
          $html_output .= "<p>".$post_id."</p>";
        }

As for pulling the data from separate tables and not getting it all mixed up, I was thinking of doing something like this:

$get_arrayA = mysql_query("SELECT * FROM tableA WHERE age = '36' ");
  while($dataA = mysql_fetch_array($get_arrayA))
  {

      $dataA_id = $dataA['id'];
      $dataA_firstName = $dataA['FirstName'];

  foreach($dataA_id)
    {
      $get_arrayB = mysql_query("SELECT * FROM tableB where id='".$dataA_id."'");
      while($dataB = mysql_fetch_array($get_arrayB))
      {

      $dataB_lastName = $dataB['LastName'];

      $html_output .= "<p>".$dataA_firstName.$dataB_lastName"</p>";

      echo $html_output;
      }
   }
}

Or would this be just too weird of a thing?

I know how to do it within SQL using inner join but how do I do something like that in PHP and output html?

  • 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-31T13:15:31+00:00Added an answer on May 31, 2026 at 1:15 pm

    It is because of you misguide use of wildcard (*) characters. STOP THAT !! This is what happens when arrogant php developers imagine that they do not need to learn SQL. If you need something , then select it.

    SELECT 
        foo.foo_id, 
        foo.data as paramX , 
        bar.type,
        bar.something_else
    FROM foo
        INNER JOIN bar USING (foo_id)
    WHERE
        foo.state = 'open'
    AND bar.type = 3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL query that: gets data from three tables linked by unique
I have four tables each with its own form, all these table share same
I have 2 tables - first table holds all unique data (columns: title, artist,
I have several tables whose only unique data is a uniqueidentifier (a Guid) column.
I have db tables in each I have same primary column name ('ID') I
I have two tables, entities and components, each with a name and unique ID.
I have two tables: poll_response (poll_id, option_id, user_id) (about 500,000 rows, with 500 unique
A brief description... I have 4 tables. contacts (a list of each person, unique
I have 2 tables. Table 1 has Product ID and Product Name (each row
I have a table being pulled from MySql through PHP.. The TD in the

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.