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
https://forums.phpfreaks.com/topic/219704-reload-the-script/
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
https://forums.phpfreaks.com/topic/219704-reload-the-script/#findComment-1139257
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.