PHP ~ 原生语法 ~ 根据从数据库查询数据之后快速输出 某个属性的值到 到页面
2024-10-08 16:16:46
一,根据 id 来查询单个的数据
<?php
require_once '../../conn.php';
$sql = "select * from blogarticle where ID = {$ID}";
$results = mysql_query($sql);
$blog = mysql_fetch_assoc($results); //将数值存储到 $blog中
mysql_free_result($results);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>name : <?php echo $blog['name']; ?> </h1>
</body>
二,输出表的所有数据
<?php
require_once '../conn.php';
@$sql = "select * from blogarticle";
@$results = mysql_query($sql);
while (@$row = mysql_fetch_assoc($results)) {
echo <<<s
<tr>
<td>{$row['title']}</td>
<td>{$row['content']}</td>
<td>{$row['class']}</td>
<td>{$row['author']}</td>
<td>{$row['date']}</td>
<td>
<a href="../logic/article/delete.php?ID={$row['ID']}">删除 </a>|
<a href="../logic/article/update.php?ID={$row['ID']}">修改</a>
</td>
</tr>
s;
}
mysql_close();
?>
最新文章
- PHP实现多图片上传
- 关于GPL的一些知识
- Eclipse连接到My sql数据库之前操作
- Javascript屏蔽回车提交表单
- 判断comboBox是否选对了绑定的数据库中的项
- 为边框应用图片 border-image
- LightOJ 1259 Goldbach`s Conjecture (哥德巴赫猜想 + 素数筛选法)
- How to enable DateTimePicker to use both date and time z
- haporoxy的keeplaive ZZ
- 如何启用第三方Chrome插件
- 【gcd】 最大公约数
- [Luogu4149][IOI2011]Race
- ES 04 - 安装Kibana插件(6.6.0版本)
- Windows 10 配置系统环境变量
- [OpenCV] Samples 18: Load image and check its attributes
- E - Mahmoud and Ehab and the bipartiteness CodeForces - 862B (dfs黑白染色)
- 使用GitHub-Pages创建博客和图片上传问题解决
- 应用Mongoose开发MongoDB(1)数据库连接
- php实现多继承-trait语法
- IOS发送Email的两种方法