當前位置:首頁 » 數據倉庫 » php資料庫網頁顯示
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

php資料庫網頁顯示

發布時間: 2022-09-21 02:35:56

⑴ 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);

⑵ 在網頁中如何將資料庫的數據顯示出來

  1. 你要有一個jsp頁面,你可以查下jsp怎麼連接對應資料庫

  2. 編寫連接資料庫的程序,以下是jsp連接oracle程序

  3. <%@page contentType="text/html;charset=gb2312"%>

  4. <%@page import="java.sql.*"%>


  5. <HTML><BODY>


  6. <hr align="center" width="55%" color="#991111" size="5"/>


  7. <%

  8. Connection conn = null;

  9. PreparedStatement stmt = null;

  10. ResultSet rs = null;



  11. request.setCharacterEncoding("GBK");


  12. try{

  13. Class.forName("oracle.jdbc.driver.OracleDriver");

  14. }

  15. catch(ClassNotFoundException ce){

  16. out.println(ce.getMessage());

  17. }

  18. try{

  19. String url="jdbc:oracle:thin:@localhost:1521:orcl";

  20. conn=DriverManager.getConnection(url,"scott","tiger");

  21. stmt=conn.prepareStatement("select * from emp");

  22. rs=stmt.executeQuery();

  23. out.print("<TABLE BORDER='1' width='55%' cellpadding='3' align=center>");

  24. out.print("<TR><TD>"+"<b>Empno</b>"+"</TD>");

  25. out.print("<TD>"+"<b>Ename</b>"+"</TD>");

  26. out.print("<TD>"+"<b>Job</b>"+"</TD>");

  27. out.print("<TD>"+"<b>Mgr</b>"+"</TD>");

  28. out.print("<TD>"+"<b>hiredate</b>"+"</TD>");

  29. out.print("<TD align=center>"+"<b>Sal</b>"+"</TD>");

  30. out.print("<TD>"+"<b>Comm</b>"+"</TD>");

  31. out.print("<TD>"+"<b>Deptno</b>"+"</TD></TR>");



  32. while(rs.next()){

  33. out.print("<TR><TD>"+rs.getString(1)+"</TD>");

  34. out.print("<TD>"+rs.getString(2)+"</TD>");

  35. out.print("<TD >"+rs.getString(3)+"</TD>");

  36. out.print("<TD>"+rs.getString(4)+"</TD>");

  37. out.print("<TD>"+rs.getString(5)+"</TD>");

  38. out.print("<TD>"+rs.getString(6)+"</TD>");

  39. out.print("<TD>"+rs.getString(7)+"</TD>");

  40. out.print("<TD>"+rs.getString(8)+"</TD></TR>");

  41. }


  42. out.print("</TABLE>");

  43. rs.close();

  44. stmt.close();

  45. conn.close();


  46. }

  47. catch(Exception e){

  48. System.out.println(e.getMessage());

  49. }


  50. %>


  51. </BODY></HTML>

⑶ 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>

謝謝謝謝謝謝碼密。的入輸要需所面。界理管台後器。由路陸登是。碼密理管。廖仲庭。器由。路。

⑷ php讀取資料庫數據無法顯示在頁面上 求教。

<?php while($row=mysql_fetch_array($result))?>
<tr bgcolor="#CCFFFF">
<td>標題:<?=$row['title']?> 用戶:<?=$row['user']?></td> </tr>
<tr bgColor="#ffffff">
<td>內容:<?=tomtmlcode($row['content']);?></td>
</tr>
<?php}?>這個地方的<?php while($row=mysql_fetch_array($result))?>少了一個{符號
<?php while($row=mysql_fetch_array($result)){ ?>還有就是最好不要用<?=這個多敲幾行代碼不行嗎?我有強迫症

⑸ 如何解決Linux環境下訪問PHP頁面時,頁面上顯示資料庫代碼的問題

出現此問題的原因是由於在.htaccess文件中添加了下面兩行:

AddHandler application/x-httpd-php53 .php

AddHandler application/x-httpd-php54 .php

在這些行的開始位置插入#注釋掉之後就可以正常使用了。

⑹ 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中如何調用資料庫中的圖片並且顯示到頁面

php是採用二進制形式存儲圖片及讀取顯示的,首先通過代碼創建數據表,然後上傳圖片伺服器再通過瀏覽器顯示,具體編程代碼舉例:

1、首先需要創建數據表,具體代碼如下圖所示。

⑻ 很簡單的一個小功能,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怎麼把資料庫的數據顯示到頁面上

使用<?php echo $data['key']?>輸出就可以