0

我正在尝试循环和淡入/淡出表格中的随机记录到我的网页中。

这是我的代码:

SQL:

SELECT businessid, bsalias, bsname, bswebsite, bsarea, bsstrapline
FROM businesses WHERE businessid >= (SELECT FLOOR( MAX(businessid) * RAND())
FROM businesses) ORDER BY businessid LIMIT 1 

HTML:

<div class="divRHSlinksml">
  <h1 class="bss">
    <a href="http://www.letsgowild.co.uk/business/<?php echo $row_rsBusiness['bsalias']; ?>"><?php echo $row_rsBusiness['bsname']; ?></a>
  </h1>
  <p class="nomarginbase bss">
    <?php if ($row_rsBusiness['bsstrapline'] != ""){
      echo $row_rsBusiness['bsstrapline'];
    } else {
      echo $row_rsBusiness['bsarea'];
    } ?>
  </p>
</div>

jQuery(在页面末尾):

<script src="http://malsup.github.com/jquery.cycle.all.js" type="text/javascript"></script>
<script type="text/javascript">
  // Slideshow
  jQuery('.bss').cycle({
    fx: 'fade',
    speed: 1000,
    random: 1
  });
</script>

目前随机记录被引入,但它不会淡入/淡出到另一条记录。

非常感谢。

4

1 回答 1

0

您的 SQL 现在限制为只有 1 条记录,将其更改为:

SELECT businessid, bsalias, bsname, bswebsite, bsarea, bsstrapline
FROM businesses WHERE businessid >= (SELECT FLOOR( MAX(businessid) * RAND())
FROM businesses) ORDER BY businessid

我没有看到您的主要 PHP 代码,但您应该遍历 SQL 查询的结果。JS 代码可以保持不变。

于 2013-07-21T12:42:06.467 回答