博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php笔记小结
阅读量:7218 次
发布时间:2019-06-29

本文共 1026 字,大约阅读时间需要 3 分钟。

读取数据库内容到页面:

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <title>Document</title>

    <style>

      *{

            background: #009899;

            position: relative;

        }

        table{

            border-collapse: collapse;

            border: 1px solid #006566;

            position: absolute;

             top: 100px;

            left: 100px;

            cursor: pointer;

            width: 800px;

          

            }

            img {

            width: 50px;

            height: 50px;

        }

       

    </style>

</head>

<body>

<div></div>

   <table >

  

   <?php

 

 $con = mysql_connect("localhost","root","root");

 if(!$con){

    die("db connection is wrong:".mysql_errno());

 }

 

 mysql_select_db("db_admin",$con);// db_admin数据库名

 

 mysql_query("set names utf8");//把数据库读出的乱码中文正常显示

 //遍历表中的数据在浏览器里输出

 $sql1 = "select * from song  limit 0,10"; // limit 0,10显示数据库前10行,song为表名

 $str = mysql_query($sql1);

 while($infor = mysql_fetch_array($str)){

    echo "<tr><td>".$infor['id']."</td>

<td>". $infor['song_name']."</td>

<td><img src='". $infor['song_icon_url']."'></td>

<td><audio controls src='song/". $infor['song_url']."'></audio></td></tr>";

 }

 mysql_close($con);

 ?>

   </table>

</body>

</html>

 

 

 

 

 

 

 

 

 

 

转载于:https://www.cnblogs.com/iriliguo/p/6363254.html

你可能感兴趣的文章
Dalvik 虚拟机 jvm 区别
查看>>
hexo从零开始
查看>>
币值转换
查看>>
RabbitMQ(六)远程连接
查看>>
得到ios设备的一些信息
查看>>
【教程】如何修改路由表?
查看>>
云计算与虚拟化之后:网络威胁成新挑战
查看>>
50个Demo展示HTML5无穷的魅力
查看>>
chapter 4:贪心
查看>>
批处理学习笔记
查看>>
Linux挂载磁盘
查看>>
Cyclone II RAM ROM设置
查看>>
Ubuntu下实现伪静态
查看>>
python 二维数组遍历
查看>>
第8周课下作业1(补)
查看>>
阿萨斯
查看>>
service启动和停止,绑定和解除绑定
查看>>
elasticsearch开机启动脚本
查看>>
window service 恢复选项卡设置
查看>>
车辆管理系统之编码过程总结(十一)
查看>>