我正在尝试构建一个片段,它将显示我的投资组合的自定义页面标题。我遇到的问题是我的代码只返回“else”,但是当我在 MySql 中运行查询时,我得到name
.
我究竟做错了什么?
<?php
// Show All Errors
error_reporting(E_ALL);
ini_set('display_errors', '1');
$getID = $modx->quote($getID);
$ret = '';
$qry = "SELECT `name` FROM `modx_gallery_items` WHERE REPLACE(LOWER(`name`), ' ', '-') = $getID;";
$result = $modx->query($qry);
if ($result) {
$row = $result->fetch(PDO::FETCH_ASSOC);
if($row){
$ret = 'o7th Web Design » Portfolio » ' . $row['name'];
}else{ //It's showing this one on the page, yet the same query in MySQL returns `name`
$ret = 'o7th Web Design » Portfolio » Our Portfolio' . $qry;
}
unset($row);
}else{
$ret = 'o7th Web Design » Portfolio » Our Portfolio' . $qry;
}
// Return everything
echo $ret;
?>