【发布时间】:2017-11-07 02:32:36
【问题描述】:
我得到的错误如下:(我也在回显查询语句)
注意:第 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 中的数组到字符串转换
*SELECT * FROM WR_TeamAnalyzer WHERE TMID = ? AND 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>'.
【问题讨论】:
-
当我打印数组时,我得到 print_r($filter);数组 ( [0] => TMID = ? [1] => WKID = ?, ? ) print_r($values);数组 ( [0] => 3 [1] => 3, 4 )
标签: php mysql arrays pdo filtering