I am trying to cycle and fade in/out random records from a table into my webpage.
Here is my code:
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 (at end of page):
<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>
At the moment a random record is brought in but it doesn't fade in/out to another record.
Many thanks.
Your SQL now limit to only 1 record, change it to:
SELECT businessid, bsalias, bsname, bswebsite, bsarea, bsstrapline
FROM businesses WHERE businessid >= (SELECT FLOOR( MAX(businessid) * RAND())
FROM businesses) ORDER BY businessid
I don't see your main PHP code but you should loop through the result from SQL query. The JS code can remain the same.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.