みんな!したがって、私がやろうとしているのは2つの部分です。最初に、「id」、「name」、「times」の列を持つ「lists」というテーブルを使用してphpMyAdminにデータベースを作成したことを知っておくことが重要です。 、「レベル」、「メール」、「番号」。(1)これらの列のすべてをIDで参照していると呼べるようにしたいと思います。(2)次に、「レベル」データ(0から3までの数値)に基づく順序付きテーブルを、低い値から高い値の順に印刷できるようにします。これにより、順序が維持されます。より多くの入力がデータベースに入れられたとしても。唯一の問題は、私が作成したWebサイトのテーブルに何も印刷されないため、(1)の実装が機能していないように見えることです。これが私が持っているものです:
// configuration
require("../includes/config.php");
for ($num = 0; $num < 255; $num++)
{
// get info from database
$rows = query("SELECT id FROM list WHERE id = ?", $num);
}
if ($rows === false)
{
apologize("Oops, something went wrong with the database.");
}
// look up list info
$positions = [];
foreach ($rows as $row)
{
$positions[] = [
"name" => $row["name"],
"times" => $row["times"],
"level" => $row["level"],
"email" => $row["email"],
"number" => $row["number"]
];
}
// render list of people
render("list_form.php", ["positions" => $positions, "title" => "List"]);
?>
ちなみに、「list_form.php」は、データの印刷先となるテーブルを含むhtmlファイルであり、理想的には「レベル」のデータ順に並べられています。
<thead>
<tr>
<th>Name</th>
<th>Times Available</th>
<th>Level of Play</th>
<th>Email Address</th>
<th>Phone Number</th>
</tr>
</thead>
<tbody>
<?php
foreach ($positions as $position)
{
printf("<tr>");
printf("<td>%s</td>", htmlspecialchars($position["name"]));
printf("<td>%s</td>", htmlspecialchars($position["times"]));
printf("<td>%s</td>", htmlspecialchars($position["level"]));
printf("<td>$%s</td>", htmlspecialchars($position["email"]));
printf("<td>$%s</td>", htmlspecialchars($position["number"]));
printf("</tr>");
}
?>
<center>
<a href="index.php">Index</a></li>
</center>
</tbody>
あなたが提供できるどんな助けにも感謝します。