スクリプトの 1 つを変更して、削除されたファイル名のテーブルを表示するように依頼された顧客がいます。これは私のサイトではないため、mysql を mysqli に変更することは許可されていません。
すべてを 1 行に並べてページ付けするのではなく、情報が 1 ページに収まるように列が必要です。いくつかの方法を試しましたが、適切に機能していないようです
方法 1: 正しい列数を表示しますが、すべてのセルで同じファイル名を繰り返します。
$q = "SELECT `name` FROM `files` WHERE `deleted` = 1";
$r = mysql_query($q);
$rows = mysql_num_rows($r);
$deleted = mysql_fetch_assoc($r);
// Build table and iterate through the results
$end = $rows; // total # of results
$t_rows =ceil($end/5); // number of cells per row
$x = 0;
$start = 0;
echo "<table>";
while($x <= $t_rows){
echo "<tr>";
for($y = 0; $y < 5; $y++, $start++){
if($start <= $end){
echo "<td>".$deleted['name']."</td>";
}
}
echo "</tr>";
$x++;
}
echo "</table>";
方法 2: 正しい列数を表示しますが、各行でファイル名を 5 回繰り返します。(例、行 1 には最初のレコードの名前が 5 回あり、行 2 には 2 番目のファイルの名前など)。
$q = "SELECT `name` FROM `files` WHERE `deleted` = 1";
$r = mysql_query($q);
$rows = mysql_num_rows($r);
// Build table and iterate through the results
$end = $rows; // total # of results
$t_rows =ceil($end/5); // number of cells per row
$x = 0;
$start = 0;
echo "<table>";
while($x <= $t_rows){
echo "<tr>";
while($deleted = mysql_fetch_assoc($r)){
for($y = 0; $y < 5; $y++, $start++){
if($start <= $end){
echo "<td>".$deleted['name']."</td>";
}
}
echo "</tr>";
$x++;
}
}
echo "</table>";