I have the following script that should show the results of the MySQL query and populate the table below but it does the table comes out empty. I know there should be results shown, but I am unsure where the syntax issue is:
<table>
<tr>
<th>Country</th>
<th>Part</th>
<th>Description</th>
<th>Quantity</th>
<th>Ship_Date</th>
</tr>
<?php
$conn = mysqli_connect("localhost", "username", "password", "dbname");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "
SELECT t1.Country
, t2.Part
, t2.Description
, Sum(t2.Quantity) AS Quantity
, t1.ship_time
FROM Table1 t1
JOIN Table_Data2 t2
ON t1.CodeValue = t2.CodeValue
WHERE t2.Part IN ('BB1234', 'BB-3454')
AND t1.ship_time = Current_Date()
GROUP
BY t1.Country
, t2.Part
, t2.Description
, t1.ship_time;
";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr><td>".$row["t1.Country"].
"</td><td>".$row["t2.Part"].
"</td><td>". $row["t2.description"].
"</td><td>" .$row["t2.quantity"].
"</td><td>". $row["t1.ship_time"]. "</td><td>";
}
echo "</table>";
} else {
echo "0 results";
}
$conn->close();
?>
</table>
No error messages come up but I suspect the error may be when I do echo "<tr><td>".$row["t1.Country"]. for each column
echo "<tr><td>".$row["t1.Country"].for each header