데이터베이스 테이블 명세서 만들기
데이터베이스 테이블을 웹상에서 편리하게 보기위해 제작해봤습니다.
<html>
<head>
<title></title>
<!-- JQUERY -->
<link href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet">
<script src="//code.jquery.com/jquery.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<!-- font-awesome ICON -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<!-- bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<style>
table th { background-color:#F1F1F1; }
</style>
</head>
<body>
<div class="container">
<?php
$DB = array();
$DB['prefix'] = "";
$DB['host'] = "";
$DB['name'] = "";
$DB['id'] = "";
$DB['pwd'] = "";
$DB['connect'] = mysqli_connect(
$DB['host'],
$DB['id'],
$DB['pwd']
);
$DB['db_select'] = mysqli_select_db(
$DB['connect'],
$DB['name']
);
$table_desc = array(
);
$html = "";
$html .= "<h3>총 테이블 카운트 : <span id='table_count'></span></h3>";
$sql = "SHOW TABLE STATUS LIKE '%%'";
$rec = mysqli_query($DB['connect'], $sql);
$count = 0;
while($tb = mysqli_fetch_assoc($rec))
{
$html .= "
<div class='alert alert-info' style='margin-bottom:0px;'>
<p>테이블명 : {$tb['Name']}</p>
<p>테이블 설명 : {$tb['Comment']}</p>
</div>
";
if($table_desc[$tb['Name']]){
$html .= "<h3><span style='color:blue;'>추가설명</span> : ".$table_desc[$tb['Name']]."</h3>";
}
$html .= "
<table class='table' style='margin-bottom:50px;'>
<thead>
<tr>
<th>Field</th>
<th>Type</th>
<th>Null</th>
<th>Key</th>
<th>Default</th>
<th>Extra</th>
<th>Comment</th>
</tr>
</thead>
<tbody>
";
$sql = "SHOW FULL COLUMNS FROM {$tb['Name']}";
$recSub = mysqli_query($DB['connect'], $sql);
while($field = mysqli_fetch_assoc($recSub))
{
$html .= "
<tr>
<td>{$field['Field']}</td>
<td>{$field['Type']}</td>
<td>{$field['Null']}</td>
<td>{$field['Key']}</td>
<td>{$field['Default']}</td>
<td>{$field['Extra']}</td>
<td>{$field['Comment']}</td>
</tr>" . PHP_EOL;
}
$html .= "
</tbody>
</table>
" . PHP_EOL;
$count++;
}
echo $html;
?>
<script>
$(document).ready(function(){
$("#table_count").html("<?=$count?>");
});
</script>
</div>
</body>
</html>
댓글 13개
위 링크에서 제가 본적은 있긴한데
원글을 작성하신분이 맞다면 올리는거야 문제없겠지만..
만약 아니라면 해당 작성자한테 이야길하는게 좋지않을까 합니다.
와 그런데 제 홈페이지에 들어오신적도 있고 영광입니다 ^^;
즐겨찾기 되어있습니다.^^
SHOW TABLE STATUS LIKE '%%';
를
SHOW TABLE STATUS;
로 변경하셔도 될 것 같네요.
원래 취지는 "g5_" 처럼 prefix 가 들어가야 하는데 제가 삭제한 거예요 ^^;
그럼 LIKE 'g5_%' 가 맞겠네요 ^^
게시판 목록
그누보드5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 공지 | 3년 전 | 4404 | ||
| 2604 | 8개월 전 | 673 | ||
| 2603 | 8개월 전 | 733 | ||
| 2602 | 8개월 전 | 648 | ||
| 2601 |
|
8개월 전 | 671 | |
| 2600 |
|
8개월 전 | 579 | |
| 2599 | 8개월 전 | 809 | ||
| 2598 | 8개월 전 | 602 | ||
| 2597 |
다케미카코
|
8개월 전 | 756 | |
| 2596 | 8개월 전 | 854 | ||
| 2595 |
|
8개월 전 | 446 | |
| 2594 | 9개월 전 | 608 | ||
| 2593 |
만두먹고또먹고
|
9개월 전 | 936 | |
| 2592 | 9개월 전 | 610 | ||
| 2591 | 9개월 전 | 620 | ||
| 2590 | 9개월 전 | 688 | ||
| 2589 |
|
9개월 전 | 758 | |
| 2588 | 9개월 전 | 476 | ||
| 2587 | 9개월 전 | 796 | ||
| 2586 | 9개월 전 | 643 | ||
| 2585 | 9개월 전 | 510 | ||
| 2584 | 9개월 전 | 576 | ||
| 2583 | 9개월 전 | 498 | ||
| 2582 | 9개월 전 | 642 | ||
| 2581 | 9개월 전 | 598 | ||
| 2580 |
만두먹고또먹고
|
9개월 전 | 517 | |
| 2579 |
|
9개월 전 | 664 | |
| 2578 | 9개월 전 | 647 | ||
| 2577 | 9개월 전 | 627 | ||
| 2576 | 9개월 전 | 562 | ||
| 2575 |
이슈DEV
|
10개월 전 | 993 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기