I need to select data from both tables and display it but my PHP file seems to be posting duplicates. I want to be able to pick up all of the descriptions and relate it to the ID's which are used in table1.
I managed to get some of it to work but it displays the name Jake twice is their anyway i can filter out the duplicates.
Thanks
Here is my code
$sql = "SELECT table1.name, table2.description
FROM table1
INNER JOIN table2
on table1.id = table2.customerid";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo $row['name']."<br>";
echo $row['description']."<br>";
}
table1
id name
1 james
2 jake
3 aaron
4 holly
table2
id customerid description
1 1 hey1
2 2 hey2
3 2 hey3
4 3 hey4
5 4 hey5