U E D R , A S I H C RSS

이승한/mysql

/mysql

PHP공부를 mysql 구 공부.

기본

mysql 맨드 모드 된다.
ASP.net <form>만 가 만 PHP HTML 그렇 다.
다면. mysql -u root -p (u: user, p: password)
MySql 명령 방법
  • MySql
  • PHP MySql API

mysql - 두부 - 블들. //mysql - 블 로 다. // 다르게 는듯 다.

두부

두부 목록보기 : show databases; ( s가 들다.)
두부 만들기 : create database 두부;
두부 기 : drop database 두부;
두부 기 : use 두부;

두부 기 : create table 블명(럼명 type(기), eng integer, date date);
기 : drop table 블명;
블들보기 : show tables;
목보기 : show colums from 블명;
럼들 보기 : ??;

key

류 : index, unique, primary
: add index (드명, );

드관련 명령 <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 <>

드관련 명령 <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);
	}
?>
 

Thread

MySQL . 몰랐다면 고~ --Leonardong

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:31
Processing time 0.0125 sec