|
<?
require_once( "./mwin.php" );
?>
<HTML>
<HEAD>
<META http-equiv="Content-type" content="text/html; charset=euc-jp">
<TITLE>PHP 雛形</TITLE>
<LINK rel="stylesheet" type="text/css" href="style.css">
<STYLE type="text/css">
</STYLE>
</HEAD>
<BODY id="body">
<?
if ( $_GET['type'] == '' ) {
print mystr( "テーブルを選択するかクエリーを実行して下さい" );
exit();
}
// 接続とDB選択
$link = mysql_connect($host, $user, $pass);
if ( !$link ) {
print mystr( "接続エラー" );
exit();
}
mysql_select_db( $db, $link );
// SQL の指定
if ( $_GET['type'] == '1' ) {
$sql = "select * from `" . todbstr($_GET['table']) . "`";
}
if ( $_GET['type'] == '2' ) {
$sql = todbstr($_GET['text']);
}
if ( $_GET['type'] == '3' ) {
$sql = "SHOW COLUMNS FROM `" . todbstr($_GET['table']) . "`";
}
$result = mysql_query($sql);
if ( $result === TRUE ) {
print mystr( "処理は実行されました<br>" );
print $_GET['text'] . "<br>";
exit();
}
// SQL のエラー処理
if (!$result) {
print mystr( "SQLエラー<br>" );
print dbstr(mysql_error());
exit();
}
// 一覧作成
$nField = mysql_num_fields( $result );
print "<TABLE border='0' cellspacing='1' cellpadding='3'>\n";
print "<TR>\n";
print " <TH nowrap></TH>\n";
for( $i = 0; $i < $nField; $i++ ) {
$name = mysql_field_name ( $result, $i );
print " <TH nowrap>" . dbstr($name) . "</TH>\n";
}
print "</TR>\n";
$nCount = 0;
while ($row = mysql_fetch_row($result)) {
print "<TR>\n";
print " <TD>" . ($nCount + 1) . "</TD>\n";
for( $i = 0; $i < $nField; $i++ ) {
print " <TD>" . dbstr($row[$i]) . "</TD>\n";
}
print "</TR>\n";
$nCount++;
if ( $nCount >= 100 ) {
break;
}
}
print "</TABLE>";
mysql_free_result($result);
// 接続解除
mysql_close($link);
?>
</BODY>
</HTML>
| |