English 中文(简体)
如何在某些时间上展示不同网站?
原标题:How to show different websites in php for certain amounts of time?
  • 时间:2012-01-15 04:03:04
  •  标签:
  • php
  • mysql

我期望制作一个网页,显示一个随机网站(现有网页),只显示15秒,然后显示另一个网页等。 我希望网页能够从MySQL数据库中显示网站清单。

I m not sure if this is possible to do in PHP because I know you can use iframes in Javascript, but if it s possible I d like to do it in PHP. If anyone could point me in the right direction or write a little bit of code it would be greatly appreciated.

最佳回答

在您的“超文本编码”上添加:

<meta http-equiv="refresh" content="15;url=http://www.yourdomain.com">

然后,你可以每隔一段时间用不同的机子接上这一页。


例如:

<!DOCTYPE html>
<html>
    <head>
        <title>Random website</title>
        <meta http-equiv="refresh" content="15;url=http://www.yourdomain.com">
    </head>
    <body>
        <iframe src="<?php echo $website_pulled_from_database; ?>"></iframe>
    </body>
</html>
问题回答

You can use the sleep function in PHP instead of using jS if u are so adament on using pure PHP. But I see no point in doing that. http://php.net/manual/en/function.sleep.php You should also look into ajax in PHP.

You can use header() in PHP

header( refresh:15;url=http://www.google.com/ );

以上编码将在15秒后将用户转至谷歌。

确实,我原想一味需要用纯粹的购买力平价来做到这一点。 您可以检索亚洲开发银行的内容,并在你希望使用java书写字时展示这些内容。 您可以将规定的间隔期功能用于javascript(jQuery)。

for. eg:

<script type="text/javascript">  
  $(function(){  
        var i=0;  
         $( li ).not( :first ).hide();//Hide everything other than the first li item  
          setInterval(function(){  
              $( li ).eq(i).hide();//Hide the current li item  
              i++;    
              if($( li ).eq(i).text().length==0) //check if it is the last li item  
                {  
                 i=0;  
                }  
              $( li ).eq(i).fadeIn(1000); //FadeIn the next li item              
             },3000);                  
       });        
</script> 

Hope this was of some help for you.





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签