I am trying to combine 2 tables of data. However, all of my results were getting stuck in one set of results. I need the results to go across multiple. Someone posted a reply to that post with a code snippet and said some stuff that I didn't quite understand. I have now managed to figure out one of the errors that his code had (he used a different variable for the SQL connection) and I am now stuck with this error:
Here is what Is happening:
<?php
$con = new mysqli("-", "-", "-", "-");
$con->set_charset('utf8mb4');
//Retrieve all the data from the Update Log Table
$result = $con->query("SELECT StreamDayID, WeekColor, DayName, StreamTitle, StreamGame, TIME_FORMAT(StartTime, '%r') AS StartTime, DATE_FORMAT(StreamDate, '%D %b') AS StreamDate FROM `WeekData` WHERE WeekColor='Blue'") or die(mysql_error());
//Retrieve all the data from the Update Log Table
//$joinresult = $con->query("SELECT JoinID, JoinedBy, StreamID FROM `JoinedBy` INNER JOIN `WeekData` ON StreamID = StreamDayID") or die(mysql_error());
echo "<div id='blue' class='day'>";
echo "<h1 class='row'>Blue:</h1>";
//keeps getting the next row until there are no more to get
while($row = mysqli_fetch_array($result)){
$joinresult = $con->stmt_init();
$joinresult->prepare("SELECT JoinID, JoinedBy, StreamID FROM `JoinedBy` WHERE StreamID = ?");
// if `StreamDayID` is an integer, change "s" -> "i"
$joinresult->bind_param("s", $row['StreamDayID']);
$exec = $joinresult->execute();
if(!$exec){
// error
die(mysql_error());
}
//Print out the contents of each row into a table
echo "<div id='blue";
echo $row['StreamDayID'];
echo "' class='les'>";
echo "<div class='title'>";
echo "<h2>";
echo $row['StreamTitle'];
echo "</h2>";
echo "</div>";
echo "<div class='detail'>";
echo "<h4>Day: ";
echo $row['DayName'];
echo "</h4>";
echo "<h4>Game: ";
echo $row['StreamGame'];
echo "</h4>";
echo "<h4 class='joiners'>Joined By:";
while($join = mysqli_fetch_array($joinresult)){
echo "<a class='delink' href='https://twitch.tv/";
echo $join['JoinedBy'];
echo "'>";
echo $join['JoinedBy'];
echo "</a>";
};
echo "</h4>";
echo "<h4>Start Time: ";
echo $row['StartTime'];
echo "</h4>";
echo "<h4>Stream Date: ";
echo $row['StreamDate'];
echo "</h4>";
echo "</div>";
echo "</div>";
};
?>