我想在页面刷新或重新加载时通过循环顺序仅显示数据库表中的一个引用。我不想随意做。循环如:1,2,3 ....然后回到1.我需要使用php或jquery做到这一点。请帮忙
答案 0 :(得分:1)
将此视图编号存储在会话中,如下所示:
<?php
session_start();
$_SESSION['views'] = 1; // store session data
echo "Pageviews = ". $_SESSION['views']; //retrieve data
?>
答案 1 :(得分:0)
您可以使用当前索引设置cookie,每次访问只需将其递增一个。
答案 2 :(得分:0)
session_start();
if (!$_SESSION['c'])
{
$_SESSION['c'] = 0;
}
if ($_SESSION['c'] == 10)
{
$_SESSION['c'] = 0;
}
$_SESSION['c']++;
$result = mysql_query("SELECT * FROM cycle WHERE id = ".$_SESSION['c']);
$row = mysql_fetch_assoc($result);
echo $row['id'];
答案 3 :(得分:0)
session_start();
if (empty($_SESSION['quote_num']) || !is_numeric($_SESSION['quote_num']) || $_SESSION['quote_num'] >= 10) {
$_SESSION['quote_num'] = 1;
} else {
$_SESSION['quote_num'] += 1;
}
// Now execute your query. Make sure to do proper escaping of your query.
// SELECT .... WHERE quote_num = $_SESSION['quote_num']