gpt4 book ai didi

php - 明显不工作

转载 作者:行者123 更新时间:2023-11-29 21:31:23 26 4
gpt4 key购买 nike

1.

select sub_category from add_skills where skillax_id='28'

2.

select distinct skillax_id from add_skills where sub_category in('Nutrition 101','All About Juicing','Make Up 101')

上述方式工作不同,但当我使用...

select distinct skillax_id from add_skills where sub_category in('".$na['sub_category']."')

喜欢这个明显不起作用


  • select * from users where skillax_id in('28','23','5')
  • 最佳答案

    如果 id 为整数值,则可以使用 php 的 implode 函数。见下文:

    <?php
    $query = "select distinct skillax_id from add_skills where sub_category in(".implode(",",$na['sub_category']).")";
    ?>

    如果有字符串作为类别名称,则使用下面的代码。

    <?php
    $str = "";
    if(!empty($na['sub_category']))
    {
    foreach($na['sub_category'] as $key=>$val)
    {
    if($str == "")
    $str .= "'".$val."'";
    else
    $str .= ",'".$val."'";
    }
    $query = "select distinct skillax_id from add_skills where sub_category in(".$str.")";
    }
    ?>

    关于php - 明显不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35223958/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com