这是我为该页面运行的所有查询。这里有问题的查询是 query2
<?php
try
{
$pdo = new PDO('mysql:host=localhost;dbname=danville_tpf', 'user',
'password');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->exec('SET NAMES "utf8"');
}
catch (PDOException $e)
{
$output = 'Unable to connect to the database server.';
include 'output.html.php';
exit();
}
$output = 'Theme Park Database initialized';
//include 'output.html.php';//
try
{
$park_id = $_GET['park_id'];
$query="SELECT * FROM tpf_parks WHERE park_id = $park_id";
$result = $pdo->query($query);
}
catch (PDOException $e)
{
$output = 'Unable to connect to the database server.';
//include 'output.html.php';//
}
$output = 'Sucessfully pulled park';
//include 'output.html.php';//
foreach ($result as $row)
{
$parkdetails[] = array(
'name' => $row['name'],
'blurb' => $row['blurb'],
'website' => $row['website'],
'address' => $row['address'],
'logo' => $row['logo']);
}
try
{
$park_id = $_GET['park_id'];
$query2="SELECT `name` FROM `tpf_rides` WHERE `park_id` = $park_id AND
`top_ride` = 1 ORDER BY `name` ASC";
$result2 = $pdo->query($query2);
}
catch (PDOException $e)
{
$output = 'Unable to pull rides.';
include 'output.html.php';
}
$output = 'Sucessfully pulled rides';
//include 'output.html.php';//
try
{
$park_id = $_GET['park_id'];
$query3="SELECT `url` FROM `tpf_images` WHERE `park_id` = $park_id ORDER
BY RAND() LIMIT 1";
$result3 = $pdo->query($query3);
}
catch (PDOException $e)
{
$output = 'Unable to pull image.';
include 'output.html.php';
}
$output = 'Sucessfully pulled image';
//include 'output.html.php';//
?>
这是结果应该显示的地方
<ul>
<?php foreach ($result2 as $row2): ?>
<li><h3><?php echo $row2['name']; ?></h3></li>
<?php endforeach; ?>
</ul>
<hr>
<?php
if ($count2 = $results2->rowcount() < 1)
{
echo "No results found";
}
else
{
echo "<h2>Top Attractions</h2>";
foreach ($result2 as $row2){
echo "<li><h3>{$row2['name']}</h3></li>";
}
}
?>
现在是第 133 行if ($count2 = $results2->rowcount() < 1)