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
Why don’t you use SQL? This language is designed to do things like this.
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:
PHP resources: