Hi Stackoverflow members!
I got this dilemma:
users ID username firstname middlename lastname
1 bilbodog Casper Thomsen
2 bilbodog2 Smith John Andersen
flirts flirter_id flirted_id date time
1 2 X X
I wanna get all the flirted_id's made by the flirter_id '1' and compare the flirted_id to users and gather the firstname, middlename & lastname from the flirted_id. Plus I wanna gather the date and time from the flirts table. Then I wanna echo the results out in a HTML table.
So for now I am doing this:
<?php
$ID=$_SESSION['ID'];
// Create connection
$conn = new mysqli($mysql_hostname, $mysql_user, $mysql_password, $mysql_database);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT flirted_id, date, time FROM flirts WHERE flirter_id='$ID'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
----> ECHO TABLE <----
} else {
echo 'No flirts found.';
}
$conn->close();
?>
But that does not work.
I am so stuck at this point. I dunno how to gather 3 results from 1 table and use one of the results to compare at table 2, to gather the firstname, middlename and lastname of the person that goes by that ID.
- Thanks in advance!
</div>