MySQL の窓 ( ソース : euc-jp, クライアント : euc-jp, DB : shift_jis )


  frame.htm




シンプルな SQL ツールです。
ソースコードとクライアントのキャラクタセットは euc-jp で書いていますが、php が書ける人ならば変更は可能です。

通常は以下のみ変更します
$jdb = $sjis; // データベースのキャラクタセット
$host = "localhost"; // データベースのあるサーバー
$db = "lightbox"; // データベース名
$user = "root"; // ユーザー名
$pass = ""; // パスワード

データベースのキャラクタセットに注意して下さい。
データベースのキャラクタセットの動作確認は shift_jis、euc-jp,utf-8 で行いました。

ダウンロード

  

<HTML>
<HEAD>
<TITLE>MySQL の窓</TITLE>
<META http-equiv="Content-type" content="text/html; charset=euc-jp">
</HEAD>
<FRAMESET id="TopFrame" cols="200,*">
	<FRAME name="Left" src="left.php">
	<FRAMESET id="SubFrame" rows="240,*">
		<FRAME name="Head" src="head.php">
		<FRAME name="Body" src="body.php">
	</FRAMESET>
</FRAMESET>
</HTML>
  

  mwin.php




  

<?
$debug = FALSE;

mb_language( "ja" );
mb_internal_encoding("EUC-JP");

$euc = "EUC-JP";
$sjis = "SJIS";
$utf8 = "UTF-8";

$jclient = $euc;		// クライアントのキャラクタセット
$jdb = $sjis;		// データベースのキャラクタセット
$host = "localhost";	// データベースのあるサーバー
$db = "lightbox";		// データベース名
$user = "root";		// ユーザー名
$pass = "";		// パスワード

if ( $jclient == $euc ) {
	header( "Content-Type: text/html; Charset=euc-jp" );
}
if ( $jclient == $sjis ) {
	header( "Content-Type: text/html; Charset=shift_jis" );
}
if ( $jclient == $utf8 ) {
	header( "Content-Type: text/html; Charset=utf-8" );
}
header( "Expires: Wed, 31 May 2000 14:59:58 GMT" );

foreach( $_GET as $Key => $Value ) {
	if ( $jclient == $sjis ) {
		$_GET[$Key] = str_replace("\\\\", "\\", $Value );
	}
	$_GET[$Key] = str_replace("\\'", "'", $_GET[$Key] );
	$_GET[$Key] = str_replace("\\\"", "\"", $_GET[$Key] );
}

if ( $debug ) {
	print "<PRE>\n";
	print_r( $_GET );
	print "</PRE>\n";
}

function mystr( $eucstr ) {

	global $jclient,$euc;

	if ( $jclient != $euc ) {
		return mb_convert_encoding( $eucstr, $jclient, $euc );
	}
	else {
		return $eucstr;
	}

}
function dbstr( $str ) {

	global $jclient,$jdb;

	if ( $jclient != $jdb ) {
		return mb_convert_encoding( $str, $jclient, $jdb );
	}
	else {
		return $str;
	}

}
function todbstr( $str ) {

	global $jclient,$jdb;

	if ( $jclient != $jdb ) {
		return mb_convert_encoding( $str, $jdb, $jclient );
	}
	else {
		return $str;
	}

}
?>
  

  left.php

  

<?
require_once( "./mwin.php" );
?>

<HTML>
<HEAD>
<TITLE>PHP 雛形</TITLE>
<LINK rel="stylesheet" type="text/css" href="style.css">
<STYLE type="text/css">
</STYLE>
<SCRIPT language="javascript" type="text/javascript">
function SetDefaultQuery( sTableName ) {

	var obj = parent.Head.document;
	obj.getElementsByName("text")[0].value = "select * from `" + sTableName + "`";

}
</SCRIPT>
</HEAD>
<BODY id="left">

<?

// 接続とDB選択
$link = mysql_connect($host, $user, $pass);
if ( !$link ) {
	print mystr( "接続エラー" );
	exit();
}
mysql_select_db( $db, $link );

// SQL の指定
$sql = "SHOW TABLES FROM $db";
$result = mysql_query($sql);
if (!$result) {
	print mystr( "SQLエラー<br>" );
	print dbstr(mysql_error());
	exit();
}

// 一覧作成
print "<TABLE border='0' cellspacing='2'>";
while ($row = mysql_fetch_row($result)) {
	print "<TR>";
	print "<TD>";
	print "<A";
	print "	href=\"body.php?type=3&table=" . urlencode( dbstr($row[0]) ) . "\"";
	print "	target=\"Body\"";
	print ">◎</A>";
	print "</TD>";
	print "<TD>";
	print "<A";
	print "	href=\"body.php?type=1&table=" . urlencode( dbstr($row[0]) ) . "\"";
	print "	target=\"Body\"";
	print "	onClick='SetDefaultQuery(\"" . dbstr($row[0]) . "\")'";
	print ">" . dbstr($row[0]) . "</A>";
	print "</TD>";
	print "</TR>\n";
}
print "</TABLE>";

mysql_free_result($result);

// 接続解除
mysql_close($link);

?>

</BODY>
</HTML>
  

  head.php

  

<?
require_once( "./mwin.php" );
?>

<HTML>
<HEAD>
<TITLE>PHP 雛形</TITLE>
<LINK rel="stylesheet" type="text/css" href="style.css">
<STYLE type="text/css">
</STYLE>
</HEAD>
<BODY id="head">

<FORM action="body.php" target="Body">
	<TEXTAREA
		name="text"
		cols="100"
		rows="15"
	></TEXTAREA>
	<INPUT type="hidden" name="type" value="2">
	<INPUT type="submit" name="send" value="送信">
</FORM>

</BODY>
</HTML>
  

  body.php

  

<?
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>
  

  style.css

  

* {
	font-size: 12px;
}

BODY {
	background-color: #FFF8DC;
}

#body TABLE {
	background-color: black;
}
#body TD {
	background-color: white;
}
#body TH {
	background-color: green;
	color: white;
}


#left TD {
	background-color: pink;
}
  




yahoo  google  MSDN  MSDN(us)  WinFAQ  Win Howto  tohoho  ie_DHTML  vector  wdic  辞書  天気 


[webclass]
claudebot
24/03/29 09:51:43
InfoBoard Version 1.00 : Language=Perl

1 BatchHelper COMprog CommonSpec Cprog CprogBase CprogSAMPLE CprogSTD CprogSTD2 CprogWinsock Cygwin GameScript HTML HTMLcss InstallShield InstallShieldFunc JScript JScriptSAMPLE Jsfuncs LLINK OldProg OracleGold OracleSilver PRO PRObrowser PROc PROconePOINT PROcontrol PROftpclient PROjscript PROmailer PROperl PROperlCHAT PROphp PROphpLesson PROphpLesson2 PROphpLesson3 PROphpfunction PROphpfunctionArray PROphpfunctionMisc PROphpfunctionString PROsql PROvb PROvbFunction PROvbString PROvbdbmtn PROvbonepoint PROwebapp PROwin1POINT PROwinSYSTEM PROwinYOROZU PROwindows ProjectBoard RealPHP ScriptAPP ScriptMaster VBRealtime Vsfuncs a1root access accreq adsi ajax amazon argus asp aspSample aspVarious aspdotnet aw2kinst cappvariety centura ckeyword classStyle cmaterial cmbin cmdbapp cmenum cmlang cmlistbox cmstd cmstdseed cmtxt cs daz3d db dbCommon dbaccess dnettool dos download flex2 flex3 flex4 framemtn framereq freeWorld freesoft gimp ginpro giodownload google hdml home hta htmlDom ie9svg install java javaSwing javascript jetsql jquery jsp jspTest jspVarious lightbox listasp listmsapi listmsie listmsiis listmsnt listmspatch listmsscript listmsvb listmsvc memo ms msde mysql netbeans oraPlsql oracle oracleWiper oraclehelper orafunc other panoramio pear perl personal pgdojo pgdojo_cal pgdojo_holiday pgdojo_idx pgdojo_ref pgdojo_req php phpVarious phpguide plsql postgres ps r205 realC realwebapp regex rgaki ruby rule sboard sc scprint scquest sdb sdbquest seesaa setup sh_Imagick sh_canvas sh_dotnet sh_google sh_tool sh_web shadowbox shgm shjquery shvbs shweb sjscript skadai skywalker smalltech sperl sqlq src systemdoc tcpip tegaki three toolbox twitter typeface usb useXML vb vbdb vbsfunc vbsguide vbsrc vpc wcsignup webanymind webappgen webclass webparts webtool webwsh win8 winofsql wmi work wp youtube