① php如何在頁面簡單調用資料庫內容顯示出來
(1)沒錯
(2)你沒選資料庫好不好
mysql_select_db($database);
② php中如何調用資料庫中的圖片並且顯示到頁面
php是採用二進制形式存儲圖片及讀取顯示的,首先通過代碼創建數據表,然後上傳圖片伺服器再通過瀏覽器顯示,具體編程代碼舉例:
1、首先需要創建數據表,具體代碼如下圖所示。
③ php怎麼能把資料庫里的數據自動調用到網頁上顯示出來
mysql_select_db($database);
要是
<?php
$con = mysql_connect("localhost","root","");mysql_select_db($sql);
$result=mysql_query('select name from tag_cate where id=3');mysql_close($con);
?>
還是無內容顯示咋辦?sql是資料庫名。
則
<?php
$con = mysql_connect("localhost","root","");mysql_select_db($sql);
//$result是記過集好不好,還有你的輸出呢?echo?
$result=mysql_query('select name from tag_cate where id=3') or die('ERROR : '.mysql_error());if($result){
if (mysql_num_rows($result) == 0) {
while($row = mysql_fetch_assoc($result)){echo $row['name'].'';
}
}
mysql_free_result($result);
}
mysql_close($con);
④ 很簡單的一個小功能,php讀取資料庫中的數據,並顯示在網頁上
首先是一個input class=dh
查詢按鈕 class=cx
圖片框 class=tp
點擊查詢按鈕時
<script>
$(".cx").click(function(){
var dh= $('.dh').val();//獲取輸入的電話
$.post('date.php',{tel:dh},function(result){
//將獲取到的電話號碼提交給date.php文件,date.php文件 通過查詢tel='$_POST[tel]' 得到圖片地址$src,echo $src;result即使那個返回的$src
$('.tp').find('img').attr('src', result);//將圖片框內容改掉
});
});
</script>
需要jquery支持 就是頁面要載入
<script type="text/javascript" src="js/jquery.js"></script>
⑤ php如何讓資料庫中的圖片在網頁首頁滾動顯示
可以用無縫圖片滾動效果 如:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
* { margin: 0; padding: 0;}
body{ background-color:#1B1B1B}
#div1{ width: 800px; height: 150px; position: relative; margin: 100px auto;overflow: hidden;}
#div1 ul { width: 800px; height: 150px; position: relative; }
#div1 ul li { height: 150px; float: left; list-style: none; padding-right:20px;}
#div1 ul li img { width: 200px; height: 150px; display: inline-block;}
a{ color: #B4B4B4; }
</style>
<script type="text/javascript">
window.onload=function(){
var odiv = document.getElementById('div1');
var oul = odiv.getElementsByTagName('ul')[0];
var ali = oul.getElementsByTagName('li');
var spa = -2;
oul.innerHTML=oul.innerHTML+oul.innerHTML;
oul.style.width=ali[0].offsetWidth*ali.length+'px';
function move(){
if(oul.offsetLeft<-oul.offsetWidth/2){
oul.style.left='0';
}
if(oul.offsetLeft>0){
oul.style.left=-oul.offsetWidth/2+'px'
}
oul.style.left=oul.offsetLeft+spa+'px';
}
var timer = setInterval(move,30)
odiv.onmousemove=function(){clearInterval(timer);}
odiv.onmouseout=function(){timer = setInterval(move,30)};
document.getElementsByTagName('a')[0].onclick = function(){
spa=-2;
}
document.getElementsByTagName('a')[1].onclick = function(){
spa=2;
}
}
</script>
</head>
<body>
<a href="#" style=" display: block; margin:0 auto; width: 50px;">向左走</a>
<a href="#" style=" display: block; margin:0 auto; width: 50px;">向右走</a>
<div id="div1">
<ul>
<li><img src="img/1.jpg"/></li>
<li><img src="img/2.jpg"/></li>
<li><img src="img/3.jpg"/></li>
<li><img src="img/4.jpg"/></li>
</ul>
</div>
</body>
</html>
⑥ PHP執行SQL並將返回數據顯示到網頁上為什麼漢字會變成問號
是字元編碼問題
mysql字元編碼有四個級別 伺服器級,資料庫級,表級,欄位級.前三種均為默認設置,並不代表你的欄位最終會使用這三種之一字元集設置,以欄位級為准。
從資料庫中查詢數據並輸出顯示也有主要三個地方,一個就是上面所說的,二是連接字元集使用例如mysql_query('set name gbk')的語句設定,三是腳本字元集(php腳本的編碼),另外有網頁編碼字元集。
這些編碼應該一致,尤其是連接字元集與欄位字元集。
可使用 show variables like 'character%'; 來查看相關字元集設定
例如欄位字元集為utf-8 ,連接字元集為utf-8 ,php腳本為utf-8編碼 ,網頁charset為 utf-8
⑦ PHP文件在網頁里顯示部分php代碼(想顯示資料庫表裡面的數據)
因為你少寫了一個大括弧的結尾。
修改後:
<tableid="DataList1"cellspacing="0"border="0"width="100%">
<?php
$db=mysqli_connect('localhost','root','root');//連接MySQL伺服器
mysqli_select_db($db,'ticket');//選擇資料庫文件
if(mysqli_connect_errno()){
echo"Error:Couldnotconnecttomysqlticket"; exit;
}
$q="select*fromnews";//設置查詢指令
$result=mysql_query($db,$q);//執行查詢
while($row=mysql_fetch_assoc($result))//將result結果集中查詢結果取出一條
{
echo"<tr><td>".$row["news"]."</td><td>".$row["date"]."</td></tr>";exit;
}
}//就是這樣?
?>
</table>
謝謝謝謝謝謝碼密。的入輸要需所面。界理管台後器。由路陸登是。碼密理管。廖仲庭。器由。路。