:::메모장리스트:::::::::::::::::::::::::::
//memolist.html//
<HTML>
<HEAD>
<TITLE> New Document </TITLE>

</HEAD>

<BODY>
<table border=1 width=500>
<tr>
<td>번호</td>
<td>이름</td>
<td>이메일</td>
<td>메모</td>
<td>수정</td>

</tr>
<?
include "connect.php";
$query="select * from mymemo";
$result=mysql_query($query,$connect);
while($row=mysql_fetch_row($result)){
echo"<tr>
<td>$row[0]</td>
<td>$row[1]&nbsp;</td>
<td>$row[2]&nbsp;</td>
<td>$row[3]&nbsp;</td>
<td><a href=memomodifry.html?num=$row[0]>수정</a></td>
</tr>";
}
?>
</table>
<br>
<!--<a href="memo.html">메모입력</a>-->
<a href="memoinput.html">메모입력</a>
</BODY>
</HTML>


:::메모입력창:::::::::::::::::::::::::::
//memoinput.html//
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>

</HEAD>

<BODY>

<br>
<form method=post action=memoinput.php>
<table border=1 width=500>

<tr>
<td>이름</td>
<td><input type=text name=name></td>
</tr>
<tr>
<td>이메일</td>
<td><input type=text name=email></td>
</tr>
<tr>
<td>메모</td>
<td><input type=text name=memo size=50></td>
</tr>

<tr>
<td colspan=2 align=center>
<input type=submit value=전송>&nbsp;&nbsp;&nbsp;
<input type=reset value=취소>
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
:::메모입력창:::::::::::::::::::::::::::
//memoinput.php//
<?
echo "넘어온이름 --- $name<br>";
echo "넘어온메일 --- $email<br>";
echo "넘어온메모 --- $memo<br>";
$connect=mysql_connect("localhost","apple","1234");
$db=mysql_select_db("appledb",$connect);

$query="insert into mymemo values(NULL,'$name','$email','$memo')";

$result=mysql_query($query,$connect);

if($result){
echo "데이타 입력성공!";
}else {
echo "데이타 입력실패!";
}

echo "<meta http-equiv=refresh content='0 url=memolist.html'>"
?>

:::메모수정창:::::::::::::::::::::::::::
//memomodifry.html//
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>

</HEAD>

<BODY>
<?
echo "넘어온 글번호 --- $num<br>";
include "connect.php";
$query="select * from mymemo where num='$num'";
$result=mysql_query($query,$connect);
$row=mysql_fetch_array($result);
?>

<br>
<form method=post action=memomodifry.php?num=<?echo $row[num];?>>
<table border=1 width=500>

<tr>
<td>이름</td>
<td><input type=text name=name value=<?echo$row[1];?>></td>
</tr>
<tr>
<td>이메일</td>
<td><input type=text name=email value=<?echo$row[2];?>></td>
</tr>
<tr>
<td>메모</td>
<td><input type=text name=memo value=<?echo$row[3];?>> <size=50></td>
</tr>

<tr>
<td colspan=2 align=center>
<input type=submit value=전송>&nbsp;&nbsp;&nbsp;
<input type=reset value=취소>
</td>
</tr>
</table>
</form>
</BODY>
</HTML>

:::메모수정창:::::::::::::::::::::::::::
//memomodifry.php//

<?
echo "넘어온 글번호 --- $num<br>";
include "connect.php";
$query="update mymemo set name='$name', email='$email', memo='$memo' where num='$num'";

$result=mysql_query($query,$connect);

echo "<meta http-equiv=refresh content='0 url=memolist.html'>";

?>

:::메모장-DB연결:::::::::::::::::::::::::::
//connect.php//
<?
$connect=mysql_connect("localhost","apple","1234");
$db=mysql_select_db("appledb",$connect);
?>

:::메모장-DB-Table생성-MYSQL:::::::::::::::::::::::::::
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:\Documents and Settings\Administrator>mysql
ERROR 1045: ODBC@localhost 사용자는 접근이 거부 되었습니다. (Using password: 아니오)
C:\Documents and Settings\Administrator>
C:\Documents and Settings\Administrator>
C:\Documents and Settings\Administrator>mysql -u root -p mysql
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 4.0.21-nt
Type help; or \h for help. Type \c to clear the buffer.
mysql> create database appledb;
Query OK, 1 row affected (0.13 sec)
mysql> grant all on appledb.* to apple@localhost identified by 1234;
Query OK, 0 rows affected (0.16 sec)
mysql> exit
Bye
C:\Documents and Settings\Administrator>mysql -u apple -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 4.0.21-nt
Type help; or \h for help. Type \c to clear the buffer.
mysql> \s
--------------
mysql Ver 12.22 Distrib 4.0.21, for Win95/Win98 (i32)
Connection id: 3
Current database:
Current user: apple@localhost
SSL: Not in use
Server version: 4.0.21-nt
Protocol version: 10
Connection: localhost via TCP/IP
Client characterset: latin1
Server characterset: latin1
TCP port: 3306
Uptime: 48 min 7 sec
Threads: 1 Questions: 8 Slow queries: 0 Opens: 8 Flush tables: 1 Open tables: 2 Queries per second avg:
0.003
---참고.1-----------
mysql> show databaes;
ERROR 1064: SQL 구문에 오류가 있습니다. 에러 같읍니다. (databaes 명령어 라인 1)
mysql> show databases;
+----------+
| Database |
+----------+
| appledb |
+----------+
1 row in set (0.00 sec)
mysql> use appledb;
Database changed
mysql> show tables;
Empty set (0.00 sec)
mysql>
mysql> create table mymemo(num int not null auto_increment primary key,
-> name varchar(20) not null,
-> email varchar(30) not null,
-> memo varchar(100) not null);
Query OK, 0 rows affected (0.06 sec)
mysql>
mysql> memo varchar(100) not null);
ERROR 1064: SQL 구문에 오류가 있습니다. 에러 같읍니다. (memo varchar(100) not null) 명령어 라인 1)
mysql>
mysql> select * from mymemo;
+-----+------+-------+------+
| num | name | email | memo |
+-----+------+-------+------+
| 1 | 22 | 22 | 22 |
+-----+------+-------+------+
1 row in set (0.02 sec)
mysql>

---참고.2---------------------
mysql>
mysql>
mysql> create database appledb;
Query OK, 1 row affected (0.09 sec)
mysql> grant all on appledb. * to apple@localhost identified by 1234;
Query OK, 0 rows affected (0.16 sec)
mysql> exit
Bye
C:\>mysql -u apple -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8 to server version: 4.0.22-nt
Type help; or \h for help. Type \c to clear the buffer.
mysql> c
---참고.3---------------------------
mysql>
mysql> create database appledb;
Query OK, 1 row affected (0.09 sec)
mysql> grant all on appledb. * to apple@localhost identified by 1234;
Query OK, 0 rows affected (0.16 sec)
mysql> exit
Bye
C:\>mysql -u apple -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8 to server version: 4.0.22-nt
Type help; or \h for help. Type \c to clear the buffer.
mysql> exit
Bye
C:\>cd mssql
지정된 경로를 찾을 수 없습니다.
C:\>cd mysql
C:\mysql>cd bin
C:\mysql\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 80 to server version: 4.0.22-nt
Type help; or \h for help. Type \c to clear the buffer.
mysql> create database JspTestDB;
Query OK, 1 row affected (0.02 sec)
mysql> use database
ERROR 1049: Unknown database database
mysql> use database;
ERROR 1049: Unknown database database
mysql> use JspTestDB
Database changed
mysql> create table starcraft(id varchar(20),
-> name varchar(30),
-> price int(10));
Query OK, 0 rows affected (0.06 sec)
mysql> insert into statcraft values (aa1, 마린, 50);
ERROR 1146: Table jsptestdb.statcraft doesn exist
mysql> insert into starcraft values (aa1, 마린, 50);
Query OK, 1 row affected (0.00 sec)
mysql> insert into starcraft values (aa2, 드래곤,250);
Query OK, 1 row affected (0.00 sec)
mysql> insert into starcraft values (aa3, 캔디,150);
Query OK, 1 row affected (0.00 sec)
mysql> insert into starcraft values (aa4, 히드라,75);
Query OK, 1 row affected (0.00 sec)
mysql> insert into starcraft values (aa5, 뻥이요,150);
Query OK, 1 row affected (0.00 sec)
mysql> select * from starcraft;
+------+--------+-------+
| id | name | price |
+------+--------+-------+
| aa1 | 마린 | 50 |
| aa2 | 드래곤 | 250 |
| aa3 | 캔디 | 150 |
| aa4 | 히드라 | 75 |
| aa5 | 뻥이요 | 150 |
+------+--------+-------+
5 rows in set (0.00 sec)
mysql>