$conn = mysqli_connect('localhost', 'root', '密码');
if(! $conn )
{
die('Could not connect: ' . mysqli_error());
}
//echo '数据库连接成功!';
// 设置编码,防止中文乱码
mysqli_query($conn , "set names utf8");
$sql = 'SELECT id, IMEI FROM db_imei';
mysqli_select_db($conn,'test');
$retval = mysqli_query( $conn, $sql );
if(! $retval )
{
die('无法读取数据: ' . mysqli_error($conn));
}
echo '
ID | IMEI号 |
while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC))
{
echo "
{$row['id']} "."{$row['IMEI']} "."";}
echo '
';mysqli_close($conn);
?>