Jump to content

reload the script


fife

Recommended Posts

Hi

 

I have this script i wrote which show four random business from my database inline.  Now I want this script to show the four results for 5 seconds and then show another 4 businesses for 5 seconds and so on.  Can someone please point me in the right direction as to what I need to be looking up to do this as I dont know where to begin.  here is the code by the way


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


							?>
                                
                               <table id="top4tbl" width="150px" height="141px" border="0" cellpadding="0" cellspacing="5">
  									<tr>
    							<td width="150" ><div align="center"><img src="<?php echo $allUsers['image_location'];?>" /> </div></td>
    								</tr>
  									<tr>
    							<td width="150" ><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
Share on other sites

Hmm.. I would suggest using jQuery for this one...

 

But if you decide to stick with PHP I personally would start by creating a function which gets the data from database:

function somefunc()
{
...
return $resource; /* $rGetUsers */
}

 

 

then loop through the results as you have done.

while($allUsers = mysql_fetch_array(somefunc())) {
...

 

and after the while block either use php's sleep function and header redirect or just use header to do the magic:

header( 'refresh: 5; url=/thispage.php' );

 

Oh yeah, and if the header function gives some grief about ouput already started you should start output buffering at the top of your page (ob_start())

Link to comment
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.