我正在尝试显示 2 个表格,1 个用于节目,1 个用于电影,但目前每条记录显示 1 个表格
这是页面http://starsqa.com/ana-lucasey-about
这是新的代码片段:
if ($result['order'] == 1 OR $result['order'] == 2 OR $result['order'] == 6 OR $result['order'] == 4) {
$qry_stringr = "SELECT roles.starID, starName, roles.knownFor, roles.`character`, roles.`year`, most, type FROM roles INNER JOIN stars ON roles.starID = stars.starID WHERE roles.starID = {$result['starID']} ORDER BY roles.`year` DESC";
$prepr = $pdo_conn->prepare($qry_stringr);
$prepr->execute(array());
$showsArray = array();
$moviesArray = array();
while ($rowr = $prepr->fetch(PDO::FETCH_ASSOC)) {
if ($rowr['type'] == 0) {
$showsArray[] = $rowr;
}
else if($rowr['type'] == 1) {
$moviesArray[] = $rowr;
}
}
echo "<table border='1' bgColor='white'><tbody><tr bgColor='lightgrey' style='color:black;'><td><b>Show</b></td><td><b>Role</b></td><td><b>Year</b></td></tr>";
foreach($showsArray as $row) {
$most = $rowr['most'] == 1 ? ' color:#DE5635;' : '' OR $rowr['most'] == 0 ? ' color:black;' : '';
echo "<tr><td><font style='{$most}'>{$rowr['knownFor']} </font></td>
<td><font style='{$most}'>{$rowr['character']} </font></td>
<td><font style='{$most}'>{$rowr['year']}</font></td></tr>";
echo "</tbody>";
}
echo "</table><br><br>";
echo "<table border='1' bgColor='white'><tbody><tr bgColor='lightgrey' style='color:black;'><td><b>Movie</b></td><td><b>Role</b></td><td><b>Year</b></td></tr>";
foreach($moviesArray as $row) {
$most = $rowr['most'] == 1 ? ' color:#DE5635;' : '' OR $rowr['most'] == 0 ? ' color:black;' : '';
echo "<tr><td><font style='{$most}'>{$rowr['knownFor']} </font></td>
<td><font style='{$most}'>{$rowr['character']} </font></td>
<td><font style='{$most}'>{$rowr['year']}</font></td></tr>";
echo "</tbody>";
}
echo "</table><br><br>";
}