网站显示mysql数据库_如何显示从MySQL数据库的网站iframe?
您需要使用JavaScript來(lái)刷新iframe。
讓我們說(shuō)這是你的iframe:
您需要使用JavaScript進(jìn)行刷新,如果您希望從數(shù)據(jù)庫(kù)中獲取數(shù)據(jù),則需要使用AJAX。所以在javascript文件中做這樣的事情(我正在使用jQuery):
$(function(){
function refresh_iframe(){
$.get('iframe_url.php', function(data){
// set iframe src to the url that the php gave us
$('#iframe').attr('src', data);
// run this function again in 15s
setTimeout("refresh_iframe()",15000);
});
}
// run the first time
refresh_iframe()
});然后在iframe_url.php中你會(huì)有類似的東西:
$q = mysql_query("SELECT `url` from `iframe_urls`");
$results = mysql_fetch_assoc($q);
$key = array_rand($results);
echo($results[$key]['url']);
?>
總結(jié)
以上是生活随笔為你收集整理的网站显示mysql数据库_如何显示从MySQL数据库的网站iframe?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: mfc连接ubuntu mysql数据库
- 下一篇: python基础教程微信_用Python