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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:04:14+00:00 2026-05-28T06:04:14+00:00

I’ve a database which has four tables, for the sake of simplicity, I will

  • 0

I’ve a database which has four tables, for the sake of simplicity, I will call them table1, table2, table3, table4

Each table has different information but they all share a unique id, sessionid.

I’ve exportet all four tables through my PHPMyAdmin in PHP arrays. This gives me a file called mydomain.php.

Inside this, the data structure is as such:

$table1 = array(
  array('id'=>1,'sessionid'=>'12','field1_1'=>'data','field2_1'=>'data','field3_1'=>'data, 'done'=>1),
  array('id'=>2,'sessionid'=>'13','field1_1'=>'data','field2_1'=>'data','field3_1'=>'data, 'done'=>0)
);

$table2 = array(
  array('id'=>4,'sessionid'=>'12','field1_2'=>'data','field2_2'=>'data','field3_2'=>'data),
  array('id'=>6,'sessionid'=>'13','field1_2'=>'data','field2_2'=>'data','field3_2'=>'data)
);

$table3 = array(
  array('id'=>2,'sessionid'=>'12','field1_3'=>'data','field2_3'=>'data','field3_3'=>'data),
  array('id'=>5,'sessionid'=>'13','field1_3'=>'data','field2_3'=>'data','field3_3'=>'data)
);

$table4 = array(
  array('id'=>6,'sessionid'=>'12','field1_4'=>'data','field2_4'=>'data','field_43'=>'data),
  array('id'=>1,'sessionid'=>'13','field1_4'=>'data','field2_4'=>'data','field3_4'=>'data)
);

My wish is to display them according to their session id (as you can see, the id’s of each table can vary), and I want to check if the field ‘done’ in the first table is set to 1 or 0 and skip fields which are empty or has “NULL” in them.

I’ve tried some different methods, such foreach loops nested in each other but I don’t quite seem to work.

Hope for your help on how to solve this.

Sincere
– Mestika

  • 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-28T06:04:14+00:00Added an answer on May 28, 2026 at 6:04 am

    Why don’t you use SQL? This language is designed to do things like this.

    • Use JOIN statement to merge the content of the four tables.
    • Use SELECT statement to retrieve the field [done].
    • Use WHERE to filter empty strings and NULL values.

    And finally, use PHP and the mySQL features to retrieve the table values directly instead of using phpMyAdmin to export the data.

    Sample SQL statement:

    SELECT t1.sessionid, t1.done
    FROM table1 AS t1
    JOIN table2 AS t2 ON t1.sessionid = t2.sessionid
    JOIN table3 AS t3 ON t2.sessionid = t3.sessionid
    JOIN table4 AS t4 ON t3.sessionid = t4.sessionid
    WHERE t1.done IS NOT NULL
    

    PHP resources:

    • MySQL Improved Extension
    • PDO_MYSQL
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mysql database which has grown to over 200 tables in it.
I have a database which has some table and every one of them has
My database has got four columns: one , two , three and four each
I have a database which has almost 300 tables, I've just come across with
I have a database which has a NOT NULL constraint on a field, and
I’m selecting data on an old database which has an abused status column. The
When using ActionLink to render data from database which has HTML tags (ie <p>)
I have a table (session) in a database which has almost 72,000 rows. I
I need to query a Sybase database which has a lot of data in
I have a setting stored in database which has a value .jpg|.gif|.png . 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.