I've to select 2 table from mysql. After select the data from query and I would to to match for this 2 table. Code is in below
echo "<table>";
foreach($tableA as $tableA){
echo "<tr>";
echo "<td>" . $tableA['ID'] . "</td>";
echo "<td>" . $tableA['Name'] . "</td>";
echo "<td>" . $tableA['Date'] . "</td>";
// Start a new table for description
echo "<td><table>";
foreach($tableB as $tableB){
if ($tableA['ID'] = $tableB['ID']){
echo "<td>" . $tableB['Item'] . "</td>";
}
else {
// do nothing
}
}
echo "</table></td>";
echo "</tr>";
}
echo "</table>";
Table A
ID Name Date
1 Test 1 1/01/2014
2 Test 2 2/01/2014
3 Test 3 3/01/2014
4 Test 4 4/01/2014
5 Test 5 5/01/2014
Table B
ID Item
1 Tomato
1 Orange
2 Apple
2 Watermelon
3 Honeydrew
4 Pineapple
4 Durian
5 Grape
From this 2 table A and B, I select from query, but from the PHP codeigniter View, how can match this 2 table to below sample table? Please help. Join the data:
ID Name Date Item
1 Test 1 1/01/2014 Tomato
Orange
2 Test 2 2/01/2014 Apple
Watermelon
3 Test 3 3/01/2014 Honeydrew
4 Test 4 4/01/2014 Pineapple
Durian
5 Test 5 5/01/2014 Grape