我有一个包含 100,000 个位置的 mysql 表,我想将嵌套集模型应用于该表,以便我可以轻松生成有序列表。出于明显的原因,这是一项手动完成的大任务,所以我希望考虑到我的数据结构良好,它可以用 SQL(或 PHP 作为后备)编写。这是表格:
Id place county country
1 Abberly Worcestershire England
2 Abberton Worcestershire England
3 Abbey Field Essex England
4 Abbey St Bathans Scottish Border Scotland
5 Abbeycwmhir Powys Wales
我的计划是将内容传输到如下表:
id location _left _right
1 England
2 Wales
3 Scotland
4 Essex
5 Powys
6 Scottish Border
7 Worcestershire
8 Abberyly
9 Abberton
10 Abbey Field
11 Abbey St Bathans
12 Abbeycwmhir
非常感谢任何帮助!
最佳答案
MySQL 表包含 100,000 行?然后做一些类似在它前面的表格,它会在表格中显示您想要的所有内容。
<?php
$query = "SELECT id, name, country FROM table";
if ($result = mysqli_query($connect, $query)) {
while ($get = mysqli_fetch_assoc($result)) {
echo"<tr><td>" . $get['id'] . "</td>";
echo"<td>" . $get['name'] . "</td></tr>";
echo"<td>" . $get['country'] . "</td></tr>";
}
}
?>
如果有帮助就点赞
关于php - MySQL在大数据列表上自动生成嵌套集合模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17542210/