我正在尝试multiple rows in sql
在单个表格框中显示数据。格式为:
"MovieTitle" "movieReleaseYear" "directorName"
The Matrix 1999 Andy Wachowski, Lana Wachowski
whereAndy Wachowski and Lana Wachowski
来自不同的行,但聚集在一起group_concat
我在 phpmyadmin 中获取它们没有问题,但我不知道如何在 php 中显示它。
我有这个:
$sql="SELECT 725G54_5_movies.MovieTitle, 725G54_5_movies.movieProductionYear, GROUP_CONCAT( 725G54_5_director.directorName )
FROM 725G54_5_movies
JOIN 725G54_5_directed ON 725G54_5_movies.MovieID = 725G54_5_directed.movieID
JOIN 725G54_5_director ON 725G54_5_directed.directorID = 725G54_5_director.directorID
GROUP BY 725G54_5_movies.MovieTitle
ORDER BY $order ASC";
$result=mysql_query($sql);
//Presentation av kontakterna via while-sats till ett formulär
while($rows=mysql_fetch_array($result)){
echo "<tr>
<td>"; echo $rows['MovieTitle']; echo "</td>
<td>"; echo $rows['movieProductionYear']; echo "</td>
<td>";
while($director=mysql_fetch_array($rows['directorName'])){ echo $director; };
echo"</td>
</tr>";