1 Star 0 Fork 32

zh9009/家谱familytree

forked from jiehu0992/家谱familytree 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ostype.php 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
jiehu0992 提交于 2023-04-21 15:03 . 欧式族谱核心代码php7.4
<?php
$servername = "localhost"; $username = "root";$password = "root";$dbname = "database";
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
$array = array();
$sql = "SELECT MAX(dc) FROM tree_lr";
$res = mysqli_query($conn, $sql);
$test = array();
while ($row = mysqli_fetch_array($res, MYSQLI_ASSOC)) {
$test[] = $row;
}
$max = (int) $test[0]['MAX(dc)'];
for ($i = 1; $i < $max; $i++) {
$sql = "SELECT * FROM tree_lr WHERE dc = {$i}";
$res = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_array($res, MYSQLI_ASSOC)) {
$array[$i][] = $row;
}
}
$menu = '';
foreach ($array as $key => $value) {
$menu .= "<div class='level top_line'>
<div class='level_name'>{$key}世代</div>";
foreach ($value as $item) {
$menu .= '<div class="member">
<div style="" class="member_name">' . $item['name'] . '</div>
<div class="member_desc">' . $item['dad'] . '' . $item['rank'] . ',祖父:' . $item['gdad'] . ',兄弟:' . $item['brother'] . '、姊妹:' . $item['sisters'] . '。<br/>' . $item['info'] . '</div>
</div>';
}
$menu .= "</div>";
}
echo $menu;
if ($link && mysqli_ping($link)) {
mysqli_close($link);
}
?>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/d1s2/genealogy_familytree.git
[email protected]:d1s2/genealogy_familytree.git
d1s2
genealogy_familytree
家谱familytree
master

搜索帮助