<?php
$sql =" SELECT * FROM `comments` ";
$result = mysqli_query($db, $sql);
while($row = mysqli_fetch_assoc($result)){
$comment_id = $row['comment_id'];
$comment_company_id = $row['comment_company_id'];
$comment_name = $row['comment_name'];
$comment_content = $row['comment_content'];
$comment_email = $row['comment_email'];
$comment_status = $row['comment_status'];
$comment_date = $row['comment_date'];
echo "<tr>";
echo "<td>$comment_id </td>";
echo "<td>$comment_name </td>";
echo "<td>$comment_content</td>";
echo "<td>$comment_email</td>";
echo "<td>$comment_status </td>";
$sql =" SELECT * FROM `waste_collection_companies_info_table` WHERE `company_id`='$comment_company_id'";
$result = mysqli_query($db, $sql);
while($row = mysqli_fetch_assoc($result)){
$company_id = $row['company_id'];
$company_name = $row['company_name'];
echo "<td><a href ='../post.php?p_id=$company_id'>$company_name</a></td>";
}
echo "<td>$comment_date </td>";
echo "<td><a href='companies.php?source=edit_companies&p_id='>approve</a></td>";
echo "<td><a href='companies.php?delete='>disapprove</a></td>";
echo "<td><a href='companies.php?delete='>delete</a></td>";
echo "</tr>";
}
?> </tbody> </table> <?php