PHP Mysql连接并查询数据

已邀请:

llslx520

赞同来自:

<?php
$host = '127.0.0.1';
$username = 'root';
$password = '数据库密码';

$conn = mysql_connect($host, $username, $password); //连接数据库
mysql_select_db('aiezu', $conn); //相当于sql: use aiezu;

$sql = "select * from table_name";
$resource = mysql_query($sql, $conn);
mysql_close($conn);

$result = array();
while( $row = mysql_fetch_array($resource, true) ) {
    $result[] = $row;
}
print_r($result);
 

要回复问题请先登录注册