/mysql ¶
PHP공부를 mysql 구 공부.
기본 ¶
두부 ¶
두부 목록보기 : show databases; (막 s가 들다.)
두부 만들기 : create database 두부;
두부 기 : drop database 두부;
두부 기 : use 두부;
두부 만들기 : create database 두부;
두부 기 : drop database 두부;
두부 기 : use 두부;
블 ¶
두부 블 기 : create table 블명(럼명 type(기), eng integer, date date);
블 기 : drop table 블명;
블들보기 : show tables;
블 목보기 : show colums from 블명;
블 럼들 보기 : ??;
블 기 : drop table 블명;
블들보기 : show tables;
블 목보기 : show colums from 블명;
블 럼들 보기 : ??;
key ¶
드관련 명령 <SQL> ¶
드 : insert into table (colums...) values (data...);
드 : delete from <table> where <>;
블 만 남기고 드 모두 : delete from score;
블 드 보기 : select * from score; // *리 들다.
드 : update <tableName> set <colum Name> = <update val> where <>
드 : delete from <table> where <>;
블 만 남기고 드 모두 : delete from score;
블 드 보기 : select * from score; // *리 들다.
드 : update <tableName> set <colum Name> = <update val> where <>
드관련 명령 <PHP API> ¶
DB 및 리 . // xpweek때 던 java 객 방과 것 같다.
드 력
~cpp
<?
$dbconn = mysql_connect("localhost", "<userName>", "<userPassword>"); //localhost는 듯.
$is_connect = mysql_select_db("beonit", $dbconn);
if(!$is_connect) {
echo("MySql 결 다.");
} else{
echo("Hello Mysql");
}
?>
드 력
~cpp
<?
include "connect.inc"; //DB는 더
$query = "select name, eng, math from score";
$result = mysql_query($query, $dbconn);
$totalRecord = mysql_num_rows($result);
for($i =0; $i< $totalRecord; $i++){
$name = mysql_result($result, $i, 0);
echo("$name");
}
if( $totalRecord == 0 ){
echo( "된 드가 다.");
}
?>
드 력~cpp
<?
if(!$mode) {
$mode = "form";
}
if(!strcmp($mode, "form")) {
?>
<form name = "write_form" method = "post" action = "./new.html?mode=process">
: <input type = "text" name = "name" size = "10"><br>
: <input type = "text" name = "eng" size = "5"><br>
: <input type = "text" name = "math" size = "5"><br>
<input type = "submit" value = "데 리기">
</form>
<?
} else if(!strcmp($mode, "process")) {
$query = "insert into score (name, eng, math) values ('$name', '$eng', '$math')";
$result = mysql_query($query, $dbconn);
}
?>










