我得到的错误如下:(同时我正在回显查询语句)
注意:第75行/home/fanati10/public_html/wp content/themes/digital pro/page-nflwranalyzer.php中的数组到字符串转换
注意:第79行/home/fanati10/public_html/wp content/themes/digital pro/page-nflwranalyzer.php中的数组到字符串转换
*从WR_TeamAnalyzer中选择*其中TMID=?而WKID=?*
这是我的php文件
if(isset($_POST['submit']))
{
require_once( get_stylesheet_directory() . '/config/config.php' );
if(isset($_POST['check'])) {
$nflposs = "";
foreach($_POST['check'] as $val => $text_field) {
$nflposs.=$text_field.", ";
}
$nflpossint = rtrim($nflposs, ', ');
$nflposs = explode(',', $nflpossint);
$placeholders = rtrim(str_repeat('?, ', count($nflposs)), ', ');
$filter[] = "TMID = $placeholders";
$values[] = $nflpossint;
}
if(isset($_POST['wk'])) {
$wkid = "";
foreach($_POST['wk'] as $val => $text_field) {
$wkid.=$text_field.", ";
}
$wkidint = rtrim($wkid, ', ');
$wkid = explode(',', $wkidint);
$placeholders2 = rtrim(str_repeat('?, ', count($wkid)), ', ');
$filter[] = "WKID = $placeholders2";
$values[] = $wkidint;
}
$sql="SELECT * FROM WR_TeamAnalyzer WHERE " . implode(' AND ', $filter);
echo ($sql);
$selectStmt = $dbcon->prepare($sql);
$selectStmt->execute($values);
$rows = $selectStmt->fetchAll();
$tableContent = '';
foreach ($rows as $row){
$tableContent = $tableContent.'<tr>'.
最佳答案
当您在查询中使用=
时,它将需要一个字符串。但您在参数中传递数组(values
)。我不确定您在这里想要实现什么,但是如果您想签入一个数组,请将代码中的这两行更改如下:
TMID IN $placeholders
WKID IN $placeholders2
最后的查询应该如下所示:
SELECT * FROM WR_TeamAnalyzer WHERE TMID IN (?) AND WKID IN (?)