> php教程 > PHP源码 > php取出mysql数据库中所有数据

php取出mysql数据库中所有数据

PHP中文网
풀어 주다: 2016-05-25 17:10:00
원래의
1385명이 탐색했습니다.

1. [PHP]代码   

<?php
header("Content-Type:text/html; charset=utf-8");
$db_con=new mysqli("localhost","root","psd","ultrax");
if(mysqli_connect_errno()){
	exit("连接失败".mysqli_connect_error());
}
$db_con->query("set names utf8");
$result=$db_con->query("show tables");
$tables=array();
while ($row=$result->fetch_row()){
	array_push($tables, $row[0]);
}
function show_shuju($sql,$table){
	global $db_con;
	$result=$db_con->query($sql);
	$fields=$result->fetch_fields();
	$ziduan=array();
	foreach ($fields as $field){
		array_push($ziduan, $field->name);
	}
	$fidld_length=count($ziduan);
	echo "<table>";
	echo "<thead>";
	echo "<caption style=&#39;color:red&#39;>".$table."</caption>";
	echo "</thead>";
	echo "<tbody>";
	while($assoc=$result->fetch_assoc()){
		echo "<tr>";
		for($i=0;$i<$fidld_length;$i++){
			echo "<td>".$assoc[$ziduan[$i]]."</td>";
		}
		echo "</tr>";
	}
	echo "</tbody>";
	echo "</table>";
}
foreach ($tables as $value) {
	$sql="select * from ".$value;
	show_shuju($sql,$value);
}
?>
로그인 후 복사

                   

                   

관련 라벨:
php
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 추천
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿