gpt4 book ai didi

php - 获取数组的字符串

转载 作者:行者123 更新时间:2023-11-29 04:34:11 25 4
gpt4 key购买 nike

我正在使用这个获取数组的结果

$arrayResults = $_GET;

$arr = $arrayResults;

然后我用它来获取变量:

foreach ($arr['seller'] as $seller) { 
echo $seller;
}

其中输出 value 1 value 2 value 3 但是当我将它放入 MySQL 查询时它不起作用所以我需要将它们放入一个字符串中并且理想情况下有这样的东西 - < strong>“值 1”或“值 2”或“值 3”

这是我正在使用的查询

$sql_select = "SELECT * "; 
$sql_from = "from feeds,product_categories_map where feeds.seller =".dbstr( $seller )." and feeds.enabled=1 and feeds.stock=1 and feeds.deleted=0 and feeds.best_seller=1 and product_id=product_feed_id and product_feed_id!=1 ";
$sql_orderby = " ORDER BY rand()";
$sql_limit = " LIMIT 20";

$query=$sql_select . $sql_from . $sql_group . $sql_orderby . $sql_limit;
$product_results=dbselect( $query,"dbLinkInt" );

我不确定我哪里出错了。

最佳答案

假设您已经清理了您的输入,您应该以这种方式格式化您的变量

$seller = implode("','", $arrayResults); //this format the array into comma separated string

然后将您的查询更改为:

$sql_from = "from feeds,product_categories_map where feeds.seller IN ('".$seller."') and feeds.enabled=1 and feeds.stock=1 and feeds.deleted=0 and feeds.best_seller=1 and product_id=product_feed_id and product_feed_id!=1 ";

关于php - 获取数组的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48640046/

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