php mysql 查询数据库 文章提供一款简单的mysql 查询数据库数据的代码,可以查询blog里面所有数据并且显示出来。
php教程 mysql教程 查询数据库教程
文章提供一款简单的mysql 查询数据库数据的代码,可以查询blog里面所有数据并且显示出来。
session_start(); $conn=mysql_connect('localhost','root','root')or die('数据库连接错误'); mysql_select_db('demo',$conn); mysql_query("set names 'gbk'"); $us=$_session['username']; $selequery=mysql_query("select * from blog where author='$us' order by id desc")or die("查询失败"); ?> 作者: 留言标题: 留言内容:
/*
drop table if exists `blog`;
create table `blog` (
`id` int(10) not null auto_increment,
`author` varchar(50) not null,
`title` varchar(50) not null,
`content` text,
`redate` date not null,
primary key (`id`)
) engine=innodb auto_increment=5 default charset=gbk;
-- ----------------------------
-- records of blog
-- ----------------------------
insert into `blog` values ('1', 'admin', '我', '
呜呜呜
', '2010-07-31');我的
', '2010-07-31');去权威的物权法
', '2010-07-31');的弯曲的千万
', '2010-07-31');
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号