duanche4578 2019-08-07 12:50
浏览 55

由于树使用的SQL查询中的变量,JS Tree无法获取正确的数据

I am new to the platform and i'm not familiar with how i should describe better for everyone this problem but i hope that i will make it clear. I am tryng to make a website wich includes a page with a "tree". This "tree" form will include boxes, folders and files. The tree is based on the "id" and "parent id" principle. I have also a input where i take a 21 characters string and search by that string in the database. Unfortunely it is not working with the variable, is working just if i place a value in the query or a variable allready declared with the value.

I compared the value already declared with the one taken from the input and they are the same I tried to encode the variable in utf8

The query from fetch.php that doesn't load

$pr=$_GET['code'];
$pr2=utf8_encode_deep($pr);

     $sql=";with cte 
            as (select code128 as id,below as parent_id,comment as name, comment as text
            from hrdocs as h 
            where code128 = '$pr2'
            UNION ALL
            select h.code128, h.below, h.comment, h.comment
            from hrdocs as h 
            join cte 
            on h.below = cte.id)
            select *
            from cte
            order by parent_id asc;";

The query from fetch.php that works


$pr2='170720190945070507790';

     $sql=";with cte 
            as (select code128 as id,below as parent_id,comment as name, comment as text
            from hrdocs as h 
            where code128 = '$pr2'
            UNION ALL
            select h.code128, h.below, h.comment, h.comment
            from hrdocs as h 
            join cte 
            on h.below = cte.id)
            select *
            from cte
            order by parent_id asc;";

I want to be able to use that variable from input in order to have a tree just from the master type of box/folder/file that i am searching for.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等
    • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
    • ¥15 qt6.6.3 基于百度云的语音识别 不会改
    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
    • ¥20 测距传感器数据手册i2c