当前位置:首页 » 数据仓库 » 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']?>输出就可以