首页 > 解决方案 > 如何从 Javascript 库插入 MYSQL

问题描述

这是我当前使用 Javascript 库 BalkanApp 的项目

添加按钮来自库

这是模板中的编码

        template: "ula",
        nodeBinding: {
            field_0: "name",
            field_1: "title",
            img_0: "img"
        },
        nodeMenu: {
            details: { text: "Details" },
            edit: { text: "Edit" },
            add: { text: "Add" }, 
            remove: { text: "Remove" }
        }           
  });

这是我需要插入 MYSQL 的详细信息

nodes = [
{ id: 3, pid: 1, tags: ["blue"],  ppid: 2, name: "Queen Elizabeth II", img: "https://cdn.balkan.app/shared/f5.png"},
        { id: 4, pid: 3, tags: ["left-partner"], name: "Prince Philip", title: "Duke of Edinburgh", img: "https://cdn.balkan.app/shared/f3.png"}

];

这就是我现在所做的

chart.on('add', function (sender, node) {

<?php
    $sql = "INSERT INTO individual (id, pid, ppid, tags, name, title, img)
    VALUES ('node.id', 'node.pid', 'node.ppid', 'node.tags', 'node.name', 'node.title', 'node.img')";
    
    if ($mysqli->query($sql) === TRUE) {
      echo "New record created successfully";
    } else {
      echo "Error: " . $sql . "<br>" . $conn->error;
    }
    
    $conn->close();
?>
});

我在这里找到了库的解释,但仍然找不到解决方案 https://balkan.app/OrgChartJS/Docs/Menus https://balkan.app/OrgChartJS/Docs/APIReference#addEvent

标签: javascriptphp

解决方案


推荐阅读