メニュー


  メニューマスタ (MySQL)




  

create table `メニューマスタ` (
	`ID` int
	,`連番` bigint not null auto_increment unique
	,`タイトル` varchar(50)
	,`URL` varchar(100)
	,`タイプ` int
	,`タイトル2` varchar(50)
	,`URL2` varchar(100)
	,`タイプ2` int
	,`タイトル3` varchar(50)
	,`URL3` varchar(100)
	,`タイプ3` int
	,primary key(`ID`,`連番`)
)
  

マニュアルでは、
バージョン 4.1.0 以降では、属性 SERIAL を BIGINT NOT NULL AUTO_INCREMENT UNIQUE
のエイリアスとして使用できます...との事です


ID連番タイトルURLタイプタイトル2URL2タイプ2タイトル3URL3タイプ3
11WinOfSql
12
13
14
15
16
17
18
19
110







  index.php




  

通常呼び出しは

http://localhost/menu/index.php?id=1
(id はメニューID です)

メンテナンス呼び出しは

http://localhost/menu/index.php?id=1&mode=mtn
  

  

<?
# **********************************************************
# 外部ファイル
# **********************************************************
require_once( "common.php" );
require_once( "db.php" );
require_once( "model.php" );

# **********************************************************
# 定数定義
# **********************************************************
define( 'PASS_MESSAGE', 1 );
define( 'PASS_HEAD', 2 );
define( 'PASS_BODY', 3 );

define( 'VIEW_MESSAGE', 'viewmessage.php' );
define( 'VIEW_HEAD', 'view.php' );
define( 'VIEW_BODY', 'view2.php' );

# **********************************************************
# グローバル変数
# **********************************************************
$Target		= 'メニューマスタ';
$KeyName	= '';
$KeyField	= '';
$ErrMessage	= '';
$Message	= '';
$InData		= '';
$OutData	= '';
$OptionList	= '';
if ( $_POST['id'] == '' ) {
	$_POST['id'] = 1;
}

# **********************************************************
# 初期処理
# **********************************************************
$SQL = new DB( "localhost", "lightbox", "root", "" );
$SQL->Debug = FALSE;

# **********************************************************
# 処理コントロール
# **********************************************************
EditDataHead();
GetData( $SQL );
UpdateData( $SQL );

# **********************************************************
# ビュー
# **********************************************************
CreateInData( );
require_once( VIEW_HEAD );


# **********************************************************
# 終了処理
# **********************************************************
$SQL->Close();

# **********************************************************
# デバッグ
# **********************************************************
#DispData();
?>
  

  model.php

  

<?
# **********************************************************
# SQL文字列作成用
# **********************************************************
function SetCond( &$Value ) {

	if ( $Value == "" ) {
		$Value .= " where ";
	}
	else {
		$Value .= " and ";
	}

}

# **********************************************************
# データベースデータの読出し
# **********************************************************
function GetData( &$SQL ) {

	global $Left;

	global $Target,$KeyField,$KeyName;

	$Query = 'select * from ' . $Target;
	$Cond = " where ID = {$_POST['id']} order by 連番";

	$Column = $SQL->QueryEx( $Query . $Cond );

	$Cnt = 0;
	while ( $Column ) {
		$Cnt++;
		EditQueryData( $Column, $Cnt );
		$Column = $SQL->QueryEx( );
	}

}

# **********************************************************
# データベースデータの編集
# **********************************************************
function EditQueryData( &$Column, $Cnt ) {

	global $Left,$Mid,$Right;

	if ( $_POST['mode'] == 'mtn' ) {
		$Left[$Cnt] = "<INPUT size=50 name=IUL{$Column['連番']}";
		$Left[$Cnt] .= " type=text value='{$Column['URL']}'><br>";
		$Left[$Cnt] .= "<INPUT size=50 name=ITL{$Column['連番']}";
		$Left[$Cnt] .= " type=text value='{$Column['タイトル']}'>";
		$Mid[$Cnt] = "<INPUT size=50 name=IUM{$Column['連番']}";
		$Mid[$Cnt] .= " type=text value='{$Column['URL2']}'><br>";
		$Mid[$Cnt] .= "<INPUT size=50 name=ITM{$Column['連番']}";
		$Mid[$Cnt] .= " type=text value='{$Column['タイトル2']}'>";
		$Right[$Cnt] = "<INPUT size=50 name=IUR{$Column['連番']}";
		$Right[$Cnt] .= " type=text value='{$Column['URL3']}'><br>";
		$Right[$Cnt] .= "<INPUT size=50 name=ITR{$Column['連番']}";
		$Right[$Cnt] .= " type=text value='{$Column['タイトル3']}'>";
	}
	else {
		if ( $_POST['send'] != '' ) {
			$Left[$Cnt] = "<INPUT size=50 name=IUL{$Column['連番']}";
			$Left[$Cnt] .= " type=text value='{$_POST["IUL{$Column['連番']}"]}'><br>";
			$Left[$Cnt] .= "<INPUT size=50 name=ITL{$Column['連番']}";
			$Left[$Cnt] .= " type=text value='{$_POST["ITL{$Column['連番']}"]}'>";
			$Mid[$Cnt] = "<INPUT size=50 name=IUM{$Column['連番']}";
			$Mid[$Cnt] .= " type=text value='{$_POST["IUM{$Column['連番']}"]}'><br>";
			$Mid[$Cnt] .= "<INPUT size=50 name=ITM{$Column['連番']}";
			$Mid[$Cnt] .= " type=text value='{$_POST["ITM{$Column['連番']}"]}'>";
			$Right[$Cnt] = "<INPUT size=50 name=IUR{$Column['連番']}";
			$Right[$Cnt] .= " type=text value='{$_POST["IUR{$Column['連番']}"]}'><br>";
			$Right[$Cnt] .= "<INPUT size=50 name=ITR{$Column['連番']}";
			$Right[$Cnt] .= " type=text value='{$_POST["ITR{$Column['連番']}"]}'>";
		}
		else {
			$Left[$Cnt] = "<a href='";
			$Left[$Cnt] .= $Column['URL'];
			$Left[$Cnt] .= "' style='text-decoration:none;color:navy'>";
			$Left[$Cnt] .= $Column['タイトル'];
			$Left[$Cnt] .= "</a>";
			$Mid[$Cnt] = "<a href='";
			$Mid[$Cnt] .= $Column['URL2'];
			$Mid[$Cnt] .= "' style='text-decoration:none;color:navy'>";
			$Mid[$Cnt] .= $Column['タイトル2'];
			$Mid[$Cnt] .= "</a>";
			$Right[$Cnt] = "<a href='";
			$Right[$Cnt] .= $Column['URL3'];
			$Right[$Cnt] .= "' style='text-decoration:none;color:navy'>";
			$Right[$Cnt] .= $Column['タイトル3'];
			$Right[$Cnt] .= "</a>";
		}
	}


}

# **********************************************************
# ヘッド部の編集
# **********************************************************
function EditDataHead( ) {

	global $Target,$KeyField,$KeyName;
	global $SendButton;

	if ( $_POST['mode'] == 'mtn' ) {
		$SendButton = '<INPUT type=submit name=send value="更新">';
	}
	if ( $_POST['send'] != '' ) {
		$SendButton = '<INPUT type=submit name=send value="更新">';
	}

}

# **********************************************************
# ボディ部の編集
# **********************************************************
function EditDataBody( ) {

	global $Target,$KeyField,$KeyName;

}

# **********************************************************
# 更新処理
# **********************************************************
function UpdateData( &$SQL ) {

	global $ErrMessage,$Message;
	global $Target,$KeyField,$KeyName;

	if ( $_POST['send'] != '更新' ) {
		return;
	}

	foreach( $_POST as $Key => $Value ) {
		if ( substr( $Key, 0, 3 ) == 'IUL' ) {
			$Renban = str_replace( 'IUL', '', $Key ); 
			$Query = 'update メニューマスタ';
			$Query .= " set URL =  '$Value'" ;
			$Query .= " where id =  {$_POST['id']}" ;
			$Query .= " and 連番 =  $Renban";
			$SQL->Execute( $Query );
		}
		if ( substr( $Key, 0, 3 ) == 'ITL' ) {
			$Renban = str_replace( 'ITL', '', $Key ); 
			$Query = 'update メニューマスタ';
			$Query .= " set タイトル =  '$Value'" ;
			$Query .= " where id =  {$_POST['id']}" ;
			$Query .= " and 連番 =  $Renban";
			$SQL->Execute( $Query );
		}
		if ( substr( $Key, 0, 3 ) == 'IUM' ) {
			$Renban = str_replace( 'IUM', '', $Key ); 
			$Query = 'update メニューマスタ';
			$Query .= " set URL2 =  '$Value'" ;
			$Query .= " where id =  {$_POST['id']}" ;
			$Query .= " and 連番 =  $Renban";
			$SQL->Execute( $Query );
		}
		if ( substr( $Key, 0, 3 ) == 'ITM' ) {
			$Renban = str_replace( 'ITM', '', $Key ); 
			$Query = 'update メニューマスタ';
			$Query .= " set タイトル2 =  '$Value'" ;
			$Query .= " where id =  {$_POST['id']}" ;
			$Query .= " and 連番 =  $Renban";
			$SQL->Execute( $Query );
		}
		if ( substr( $Key, 0, 3 ) == 'IUR' ) {
			$Renban = str_replace( 'IUR', '', $Key ); 
			$Query = 'update メニューマスタ';
			$Query .= " set URL3 =  '$Value'" ;
			$Query .= " where id =  {$_POST['id']}" ;
			$Query .= " and 連番 =  $Renban";
			$SQL->Execute( $Query );
		}
		if ( substr( $Key, 0, 3 ) == 'ITR' ) {
			$Renban = str_replace( 'ITR', '', $Key ); 
			$Query = 'update メニューマスタ';
			$Query .= " set タイトル3 =  '$Value'" ;
			$Query .= " where id =  {$_POST['id']}" ;
			$Query .= " and 連番 =  $Renban";
			$SQL->Execute( $Query );
		}
	}

	return TRUE;
}

# **********************************************************
# 削除処理
# **********************************************************
function DeleteData( &$SQL ){

	global $ErrMessage,$Message;
	global $Target,$KeyField,$KeyName;

	return TRUE;
}

# **********************************************************
# ヘッド部のエラーチェック
# **********************************************************
function CheckDataHead( ) {

	global $ErrMessage;
	global $Target,$KeyField,$KeyName;

	return TRUE;
}

# **********************************************************
# ボディ部のエラーチェック
# **********************************************************
function CheckDataBody( ) {

	global $ErrMessage;
	global $Target,$KeyField,$KeyName;

	return TRUE;
}

?>
  

  view.php

  

<SCRIPT language="javascript" type="text/javascript">

// **********************************************************
// フィールドのクリア
// **********************************************************
function ClearField(){

	document.getElementsByName("In1001")[0].value = "";
}

// *********************************************************
// フォームのチェック
// *********************************************************
function CheckData() {

	return true;
}

</SCRIPT>


<HTML>
<HEAD>
<META http-equiv="Content-type" content="text/html; charset=Shift_JIS">
<TITLE>PHP 雛形</TITLE>
<STYLE>
	.MyCell {
		background-color:silver;
		height:50;
		width:200;
	}
</STYLE>
</HEAD>
<BODY>

<FORM
	name=frmMain
	method=GET
	onSubmit='return CheckData()'
>

<H1 align=center>メニュー<?= $SendButton ?></H1>

<TABLE border=0 bgcolor=black cellspacing=1 cellpadding=5 width="100%">
<TR>
	<TD class=MyCell><?= $Left[1] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Mid[1] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Right[1] ?>&nbsp;</TD>
</TR>
<TR>
	<TD class=MyCell><?= $Left[2] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Mid[2] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Right[2] ?>&nbsp;</TD>
</TR>
<TR>
	<TD class=MyCell><?= $Left[3] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Mid[3] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Right[3] ?>&nbsp;</TD>
</TR>
<TR>
	<TD class=MyCell><?= $Left[4] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Mid[4] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Right[4] ?>&nbsp;</TD>
</TR>
<TR>
	<TD class=MyCell><?= $Left[5] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Mid[5] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Right[5] ?>&nbsp;</TD>
</TR>
<TR>
	<TD class=MyCell><?= $Left[6] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Mid[6] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Right[6] ?>&nbsp;</TD>
</TR>
<TR>
	<TD class=MyCell><?= $Left[7] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Mid[7] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Right[7] ?>&nbsp;</TD>
</TR>
<TR>
	<TD class=MyCell><?= $Left[8] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Mid[8] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Right[8] ?>&nbsp;</TD>
</TR>
<TR>
	<TD class=MyCell><?= $Left[9] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Mid[9] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Right[9] ?>&nbsp;</TD>
</TR>
<TR>
	<TD class=MyCell><?= $Left[10] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Mid[10] ?>&nbsp;</TD>
	<TD class=MyCell><?= $Right[10] ?>&nbsp;</TD>
</TR>
</TABLE>

<!-- *******************************************************
 画面ID
******************************************************** -->
<INPUT type=hidden name=GNO value="<?= PASS_HEAD ?>">
<INPUT type=hidden name=id value="<?= $_POST['id'] ?>">
</FORM>

</BODY>
</HTML>
  




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


[webclass]
Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
24/04/19 12:50:15
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