基本ソースコード

  DB.PHP ( データベースアクセス用 )



  
<?
# *********************************************************
# データベースクラス
# *********************************************************
class DB {

	var $Connect;
	var $Result;

# *********************************************************
# コンストラクタ
# *********************************************************
	function DB($Server='localhost', $DbName='lightbox', $User='root', $Password='' ) {
		$this->Connect = mysql_connect( $Server, $User, $Password );
		mysql_select_db( $DbName, $this->Connect );
	}

# *********************************************************
# 接続解除
# *********************************************************
	function Close( ) {
		mysql_close( $this->Connect );
	}

# *********************************************************
# クエリー
# *********************************************************
	function Query( $SqlQuery ) {
		$ret = mysql_query( $SqlQuery,$this->Connect );
		if ( mysql_errno() != 0 ) {
			print mysql_error();
		}
		return $ret;
	}

# *********************************************************
# フェッチ
# *********************************************************
	function Fetch( $Result ) {
		return mysql_fetch_array( $Result );
	}

# *********************************************************
# クエリーとフェッチ
# *********************************************************
	function QueryEx( $SqlQuery ) {

		if ( $SqlQuery != "" ) {
			$this->$Result = $this->Query( $SqlQuery );
			if ( mysql_errno() != 0 ) {
				print mysql_error();
			}
			return $this->Fetch ( $this->$Result );
		}
		else {
			return $this->Fetch ( $this->$Result );
		}

	}


# *********************************************************
# 実行
# *********************************************************
	function Execute( $SqlExec ) {
		$ret = mysql_query( $SqlExec,$this->Connect );
		if ( mysql_errno() != 0 ) {
			print mysql_error();
		}
		return $ret;
	}

# *********************************************************
# バージョン文字列取得
# *********************************************************
	function Version( ) {
		$Field = $this->QueryEx( "show variables like 'version'" );
		return $Field[1];
	}

}
?>
  



  PAGESTART.PHP



  
<!-- *******************************************************
 画面定義
******************************************************** -->
<HTML>
<HEAD><?= HtmlCharset( "Shift_JIS" ); ?></HEAD>
<BODY>
  




  PAGEEND.PHP

  
</BODY>
</HTML>

<!-- *******************************************************
 ページロード時の初期処理
******************************************************** -->
<SCRIPT for=window event=onload language=JavaScript>

	window.focus();
	top.moveTo( 0, 0 );
	top.resizeTo( screen.width, screen.height - 32 );

</SCRIPT>
  



  FUNCTION.PHP

  
<?
# **********************************************************
# キャラクタセットを指定するMETAタグ文字列作成関数
# **********************************************************
function HtmlCharset( $Target ) {

	$strRet = '<META';
	$strRet .= ' http-equiv="Content-type"';
	$strRet .= " content=\"text/html; charset=$Target\">";

	return $strRet;

}

# **********************************************************
# デバッグ用 メッセージの表示
# **********************************************************
function DispData() {

	print "<TABLE >";
	print "<TH colspan=2>GET</TH>";
	foreach( $_GET as $Key => $Value ) {
		print "<TR>";
		print "<TD>$Key</TD><TD>$Value</TD>";
		print "</TR>";
	}
	print "</TABLE>";

	print "<TABLE >";
	print "<TH colspan=2>POST</TH>";
	foreach( $_POST as $Key => $Value ) {
		print "<TR>";
		print "<TD>$Key</TD><TD>$Value</TD>";
		print "</TR>";
	}
	print "</TABLE>";

	if ( isset( $_SESSION ) ) {
		print "<TABLE >";
		print "<TH colspan=2>SESSION</TH>";
		foreach( $_SESSION as $Key => $Value ) {
			print "<TR>";
			print "<TD>$Key</TD><TD>$Value</TD>";
			print "</TR>";
		}
		print "</TABLE>";
	}

}
?>
  



  LIST.PHP

  
<?
require_once( "db.php" );
require_once( "function.php" );
# **********************************************************
# 画面表示前のサーバ側の処理
# **********************************************************

# **********************************************************
# クライアント側に表示される画面
# **********************************************************
?>
<SCRIPT language=JavaScript>
</SCRIPT>

<? require_once( "pagestart.php" ); ?>
<!-- *******************************************************
 送信フォーム
******************************************************** -->
<FORM
	name=frmMain
	method=get
	action=<?= $_SERVER['SCRIPT_NAME'] ?>
>

	<INPUT
		name=SendButton
		type=submit
		value="検索"
	>

<HR size=1 color=black>

	<?= $LIST ?>

</FORM>
<? require_once( "pageend.php" ); ?>

<?
	DispData();
?>
  










  infoboard   管理者用   
このエントリーをはてなブックマークに追加





フリーフォントWEBサービス
SQLの窓WEBサービス

SQLの窓フリーソフト

素材

一般WEBツールリンク

SQLの窓

フリーソフト

JSライブラリ