【发布时间】:2013-09-23 13:52:22
【问题描述】:
我正在创建我的网站located here
我正在尝试添加每次页面刷新时都会更改的横幅。我在我的数据库中设置了 2 个示例,称为“链接 1”和“链接 2”。当我得到它们时,我会想添加更多。
我想要发生的事情是这样的:
我想在我的网站上显示 2 张图片中的一张,当用户刷新页面时,它将选择 2 张图片中的一张,并且每次页面刷新时都会继续。 p>
我在一个名为banner.php 的页面中对此进行了测试,然后将其移至我的footer.php 并使其生效。
我目前在banner.php 页面中有此代码:
<?PHP
include_once('include/connection.php');
// Edit this number to however many links you want displaying
$num_displayed = 1 ;
// Select random rows from the database
global $pdo;
$query = $pdo->prepare ("SELECT * FROM banners ORDER BY RAND() LIMIT $num_displayed");
$query->execute();
// For all the rows that you selected
while ($row = execute($result))
{
// Display them to the screen...
echo "<a href=\"" . $row["link"] . "\">
<img src=\"" . $row["image"] . "\" border=0 alt=\"" . $row["text"] . "\">
</a>" ;
}
?>
<br /><br /><br />
但我收到此错误代码:
致命错误:在第 13 行的banner.php 中调用未定义函数 execute()
我的连接页面被其他页面使用,所以我知道它有效。
请有人帮助我解决我做错了什么。
需要更多信息,请询问,我会将其添加到此帖子中。
谢谢。
凯夫
【问题讨论】:
标签: php mysql content-management-system banner