データベースからの結果を行ごとに 3 つの結果に分割したいと考えています。これは私が持っているコードです:
include("connect.php");
$result = mysql_query("SELECT * FROM movies ORDER BY title");
$num = mysql_num_rows ($result);
if ($num > 0 ) {
$i=0;
while ($i < $num) {
$id = stripslashes(mysql_result($result,$i,"id"));
$title = stripslashes(mysql_result($result,$i,"title"));
$description = stripslashes(mysql_result($result,$i,"description"));
$length = stripslashes(mysql_result($result,$i,"length"));
$link = stripslashes(mysql_result($result,$i,"link"));
$rating = stripslashes(mysql_result($result,$i,"rating"));
$cover = stripslashes(mysql_result($result,$i,"icover"));
$row .= '<tr><td><a href="view.php?id='.$id.'"><img width=130 height=190 src="images/covers/'.$cover.'" /></a></td><td valign="top">'.$title.'<br />'.$rating.'<br />Run Time: '.$length.'</td><td><a href="update.php?id='.$id.'">Update</a></td><td><a href="delete.php?id='.$id.'">Delete</a></td></tr>';
++$i;
}
}
else {
$row = '<tr><td colspan="2" align="center">Nothing found</td></tr>';
}
mysql_close();