Jump to content

Recommended Posts

Hi.  This is my first dip into java so I don't really know what im talking about just yet.  The issue is this.

 

I have a php loop running on my page which basically select all the records in my database and shows them inline one after the other.  Now  I want the java to show only 4 records (as that's all i can fit in my div) and then after a few seconds wipe those 4 records away and show another 4 records.

 

I've looked at many different jquery pluggins as jquery is all I understand at the moment.  I found jcaroseal and agilecarousel but they are too advanced for me at the moment.  I can use however jquery cycle but that does not support what I needed for the query I am running.  Can anybody point me in the right direction as to the script to look into please as I'm completely lost

 

  Here is my query in php;

<?php $qGetUsers = "SELECT * FROM business ORDER BY rand() ";
							$rGetUsers = mysql_query($qGetUsers) or die(mysql_error());
							while($allUsers = mysql_fetch_array($rGetUsers)) { 

?>
<table id="top4tbl" width="150px" height="140px" border="0" cellpadding="0" cellspacing="5">
  									<tr>
    							<td width="150" height="20"><div align="center"><img src="<?php echo $allUsers['image_location'];?>" /> </div></td>
    								</tr>
  									<tr>
    							<td width="150" height="20"><div align="center"><strong><?php echo $allUsers['Business_name'];?> </strong></div></td>
    								</tr>
  									<tr>

						     </tr>
  									<tr>
   								 <td width="150" height="20"><div align="center"><a href="businessinformation.php?businessid=<?php echo $allUsers['businessid'];?>">More Info</a></div></td>
   								 </tr>
							</table>
     							 <?php	}	 ?> 

 

Link to comment
https://forums.phpfreaks.com/topic/219586-image-roller-help/
Share on other sites

Heres a quick & dirty one I have made for you. If there are other tables on your page as opposed to the ones you propose to cycle through this will hide them as I have just referenced all tables in the document (I do not know what the rest of the document looks like). This can be easily changed by adding a class to your table within the loop. Make sure you change the script src attribute to wherever you have the jquery library saved.

I would suggest you run as test.html first to see it working

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cycle</title>
<!-- change src to path of jquery -->
<script type="text/javascript" src="jquery-1.4.js"></script>
<script type="text/javascript">
$(document).ready(function() {  
var counter  = 0;
var numitems = $('table').size();

function displayItems() {
	$('table').hide();
	var items = $('table').slice(counter,counter+4);
	$(items).each(function(n) {
		if($(this).is(':hidden')) {
			$(this).slideDown('slow');
		}
		counter++;			
		if(counter == numitems) {
			counter = 0;
		}
	});
	setTimeout(displayItems,5000);
}
displayItems();
});
</script>

</head>
<body>


<table>
<tr>
<td>table 1</td>
</tr>
</table>

<table>
<tr>
<td>table 2</td>
</tr>
</table>

<table>
<tr>
<td>table 3</td>
</tr>
</table>

<table>
<tr>
<td>table 4</td>
</tr>
</table>

<table>
<tr>
<td>table 5</td>
</tr>
</table>

<table>
<tr>
<td>table 6</td>
</tr>
</table>

<table>
<tr>
<td>table 7</td>
</tr>
</table>

<table>
<tr>
<td>table 8</td>
</tr>
</table>

<table>
<tr>
<td>table 9</td>
</tr>
</table>

<table>
<tr>
<td>table 10</td>
</tr>
</table>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/219586-image-roller-help/#findComment-1138500
Share on other sites

I cant thank you enough for writing me some code (which works might i add) but, its not what I need it for.  I basically need it to show me four records from my query.  Then the next four records from the list, then the next four records again and so.  The code above only refreshes the first table.  As the other three tables are created dynamically in php the java code does not refresh them.

Link to comment
https://forums.phpfreaks.com/topic/219586-image-roller-help/#findComment-1138526
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.