我有一个我正在执行的测试查询,它似乎运行正常,但是当使用varible传递或表的直接设置年份时,不会返回表行内的任何数据
<?
$curyr = date("Y");
isset($_GET['year']) ? $year = $_GET['year'] : $year = "";
$server = $_SERVER['PHP_SELF'];
$dbhost = "localhost";
$dbuname = "";
$dbpass = "";
$dbname = "";
$conn = new mysqli($dbhost,$dbuname,$dbpass,$dbname);
if($conn->connect_errno):
die("$conn->connect_error \n");
endif;
echo ("<title>$year</title>");
if (($year >= 2001) && ($year <=$curyr)) {
echo ("
<table border='0' align='center' width='100%'>
<tr>
<td>
<table border='1' align='center' width='60%' style='border:1 solid #000000; border-collapse: collapse'>
<tr>
<th align='center' colspan='5'>
DETAIL
</th>
</tr>");
$query = "SELECT c.* , p.* FROM $year c, dataset p WHERE c.id = p.id ORDER BY p.name ASC";
$r = $conn->query($query);
while ($row = $r->fetch_assoc()) {
echo ("
<tr>
<td>
$row[namepre]$row[name]
</td>
<td>
</td>
<td>
TEST
</td>
<td>
</td>
</tr>");
}
echo ("
</table>
</td>
</tr>
</table>");
} else {
echo ("ERROR NO ROWS");
}
$conn->close();
?>
我正在回复&#34;详细信息&#34;样本表顶部的一部分,但没有别的。这只是基本的,但我想知道我可能遗漏的东西。