PHP中如何连接Mysql以及读取数据
2013-02-27 17:48
696 查看
// open the connection
$conn = mysql_connect(host名, 用户名, 密码);
// pick the database to use
mysql_query("SET NAMES UTF8");
mysql_select_db(数据库名,$conn);
// create the SQL statement
$sql = "SELECT * FROM 表名";
// execute the SQL statement
$result = mysql_query($sql, $conn) or die(mysql_error());
//go through each row in the result set and display data
while ($newArray = mysql_fetch_array($result)) {
// give a name to the fields,这个只是例子
$tid = $newArray['tid'];
//以下就是各自的应用编程
}
$conn = mysql_connect(host名, 用户名, 密码);
// pick the database to use
mysql_query("SET NAMES UTF8");
mysql_select_db(数据库名,$conn);
// create the SQL statement
$sql = "SELECT * FROM 表名";
// execute the SQL statement
$result = mysql_query($sql, $conn) or die(mysql_error());
//go through each row in the result set and display data
while ($newArray = mysql_fetch_array($result)) {
// give a name to the fields,这个只是例子
$tid = $newArray['tid'];
//以下就是各自的应用编程
}
相关文章推荐
- [PHP]如何在百度(BAE)和新浪(SAE)的云平台使用PHP连接MySQL并返回结果数据
- PHP 数据库mysql链接,以及读取数据内容方式详解
- [PHP]如何在百度(BAE)和新浪(SAE)的云平台使用PHP连接MySQL并返回结果数据
- PHP5.5 mysqli如何连接MySQL数据库和读取数据
- Android 连接Mysql进行相关操作——用PHP做中介以及JSON做数据交换
- PHP_mysql_连接数据库+读取数据
- php连接mysql并读取数据
- (转)php连接mysql如何判断数据为空?
- Android 连接Mysql进行相关操作——用PHP做中介以及JSON做数据交换
- php常用代码剪辑(mysql连接数据库,web常用查询,分页,读取,js)
- mysql中的存储过程、触发器、视图是如何创建的,以及PHP中是如何调用的
- PHP连接MySQL数据的操作要点
- php PDO连接mysql以及字符乱码处理
- PHP读取MySQL数据生成Excel文件实例
- PHP 连接mysql进行简单的数据操作
- php 结合缓冲区读取excel数据并批量导入mysql
- PHP 如何向 MySQL 发送数据
- PHP读取MySQL数据代码
- php使用mysql和mysqli连接查询数据
- PHP如何查询MySQL数据页面并输出内容到页面,并另存为CSV或EXCEL文件