I want to join 2 SQL tables with same attribute but different data and display in 1 PHP Table. Table w2 and w3 and display in 1 PHP table. I am new to PHP so the Code might be very wrong.
<?php
//create database connection
require_once('C:\Users\TO115956\Documents\EasyPHP-DevServer-14.1VC11\data\localweb\projects\...\db_w2.php');
require_once('C:\Users\TO115956\Documents\EasyPHP-DevServer-14.1VC11\data\localweb\projects\...\db_w3.php');
//query the db
$query = mysqli_query($connect ,"SELECT Avis,Cde_Sap,Don_Ordre,PN_in ,SN_in,DATE2,Statut_Cde FROM w2 , w3") ;
?>
<table>
<tbody>
<?php
while($w2= mysqli_fetch_assoc($query)){
echo"<tr>";
echo"<td>".$w2['Avis']."</td>";
echo"<td>".$w2['Cde_Sap']."</td>";
echo"<td>".$w2['PN_in']."</td>";
echo"<td>".$w2['SN_in']."</td>";
echo"<td>".$w2['DATE2']."</td>";
echo"<td>".$w2['Statut_Cde']."</td>";
// echo"<td>".$w2['Employee']."</td>";
// echo"<td>".$w2['Comment']."</td>";
}//end while
while($w3= mysqli_fetch_assoc($query)){
echo"<tr>";
echo"<td>".$w3['Avis']."</td>";
echo"<td>".$w3['Cde_Sap']."</td>";
echo"<td>".$w3['PN_in']."</td>";
echo"<td>".$w3['SN_in']."</td>";
echo"<td>".$w3['DATE2']."</td>";
echo"<td>".$w3['Statut_Cde']."</td>";
// echo"<td>".$w3['Employee']."</td>";
// echo"<td>".$w3['Comment']."</td>";
}//end while
?>
<tbody>
</table>
I want to display both the SQL tables in 1 PHP table.
UNIONstatement.SELECT Avis,Cde_Sap,Don_Ordre,PN_in ,SN_in,DATE2,Statut_Cde FROM w2 UNION ALL SELECT Avis,Cde_Sap,Don_Ordre,PN_in ,SN_in,DATE2,Statut_Cde FROM w3UNIONif you want to eliminate duplicates.Union Allif you want to keep duplicates.