【发布时间】:2022-08-15 07:56:57
【问题描述】:
我正在尝试合并 2 个数据表。但是,我所有的结果都陷入了一组结果中。我需要结果跨越多个。 这是正在发生的事情:
<?php
$con = new mysqli(\"mysql.hostinger.co.uk\", \"-\", \"-\", \"-\");
$con->set_charset(\'utf8mb4\');
//Retrieve all the data from the Main Data 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 Joiners 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)){
//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>\";
};
?>