PHP MySQL을 튜토리얼
게시 : 2010년 10월 14일태그 : MySQL은 , PHP , MYSQL PHP , MYSQL PHP 튜토리얼 , 프로그래밍 , 프로그래밍 자습서
도 배우게됩니다 유일한 데이터베이스 관리 프로그램 인터넷 호스트 클라이언트는 내 SQL입니다. 그래서 수많은 전세계 - 웹 호스트가 MySQL을 제공하는 이유는 아마도 더 아래에 설명합니다. 다른 DMS MySQL과 연동하여 자주는 SQL 언어를 사용하고 대한 단일 억 달러는 올해 썬마 이크로 시스템즈에 의해 구입했습니다.
오픈 소스 소프트웨어 프로그램
MySQL의 강력한 장점 중의 사람은 데이터베이스 관리 기법이 열 공급 장치 프로그래밍을 기반으로한다는 것입니다. 이것은 그러나 그것이 프리웨어로 간주한다고 것을 의미하는 것은 아닙니다. 아니, 저기이 프로그램에 특허 함수의 숫자가 아직 없습니다 있으며 사용하는 현금을 비용. 그러나 오픈 공급 컴퓨터로 구축하여 소프트웨어 MySQL은 그들이 알아서는 사용자의 자유, 확실성이 DBMS를 수정 수 있습니다. 일반 공중 사용 허가서를 MySQL은 아래에 라이센스하는 것은 오픈 공급 코드를 가지고 있고 소프트웨어 프로그램은 고객들에게 배포으로 라이센스, 따라서 소프트웨어 패키지를, 그들에게 볼 수있는 권리를주고 변경 및 리소스 코드를 향상시킵니다. 이것은 MySQL이 그렇게 크게 잘 알려진 것으로 판명되었습니다 이유가있는 사람이다.

빠른 업데이트 및 친절한 사람
오라클과 같은 다른 데이터베이스 관리 시스템이 업데이 트 속도가 느린 경우 MySQL은 드물게 그들의 고객은 기다려주지. MySQL은 그 장소를 발견했다 같은 새로운 업그레 이드 버전 이상이 자주 나올 및 기본 서버 데이터베이스의 초기 위치와 같습니다. 알려진 그리고 네트워크 서버에 대한 선호 요원 방법으로 어떻게 리눅스 수술 프로그램과 함께 주로 사용 MySQL은 빠르고 신뢰할 수도 있습니다.
cPanel, phpMyAdmin과 MySQL
데이터베이스의 활용 초급 플랫폼의 좋은 예를 들어 많은 인터넷 호스트 cPanel, 사용하고있는 컨트롤 패널입니다. 뿐만 아니라 사람이 데이터베이스를 만들 수 있도록 비디오 자습서에 액세스할 수 있지만 phpMyAdmin 기능 많은 MySQL의 작업을 관리하는 사용자가 영상 지원을 제공합니다. 또한 MySQL이의 존재는 사람이 그 / 그녀의 웹 페이지에 대한 동적 응용 프로그램을 개발할 수 있도록 PHP 스크립트를 제공하기 위해 수많은 단어를 다양한 웹 호스트 수
1.)하여 CCCA IDX 웹 디자인
PHP와 MySQL을 기반으로 컨텐츠 관리 시스템입니다. 모든 파워풀하고 간단한 CMS. 종합 기능. 가격은 작은 회사 합리적인 것으로 보인다. 설치하기 쉽고 사용자 친화. 단 모든 가능한 IDX 웹 디자인의 클라이언트. IDX 웹 디자인을 문의하고 견적 요청
웹 사이트와 강력한 온라인 애플 리케이션을 구축할 수있게 수상 경력에 빛나는 콘텐츠 관리 시스템 (CMS). 의 용이성의 사용과 확장성 등 많은 부분은, Joomla 사용할 수있는 가장 인기있는 웹 사이트의 소프트웨어를 만들었습니다. 무엇보다도, Joomla 모두 자유롭게 사용할 수있는 오픈 소스 솔루션입니다.
최첨단 미학, 웹 표준 및 가용성에 초점을 맞춘 출판 플랫폼입니다. 워드 프레스가 동시에 무료로 귀중한 모두입니다.
더 간단하게, 워드 프레스는 블로그 소프트웨어와 작동하도록하고 싶을 때 사용 뭐, 그것을 싸우지 않을 것입니다.
4.) Soholaunch
는 유지 관리, 구축하고, 개인 또는 비즈니스 웹 사이트를 관리하는 데 도움이되는 웹사이트 제작 도구를 사용하기 쉬운. 그것은 쉽게, 온라인 쇼핑 카트 주문을 받아 양식을 작성하고, 세계의 모든 컴퓨터에서 사이트 페이지를 편집하고, 웹사이트에서 바로 실행!
5.) Drupal
사용자의 개인이나 지역 사회에 쉽게 게시할 수있는 무료 소프트웨어 패키지, 관리하고 웹사이트에 콘텐츠를 다양한 구성. 사람과 조직 수만은 Drupal을 사용하여 다른 웹 사이트의 파워 점수에
우리가해야 할 첫번째 일은 데이터베이스에 연결할 수 있습니다.
mysql_connect("somehost", "username", "password") or die ("Can't connect!");
This will try to connect to the database on somehost and login with “username” as the username and “password” as the password. If it can’t, it will output an error message saying that it can’t connect. For your own code be sure to change somehost to your host (most of the times it’s localhost, ask your admin), username to your username (duh), and password to your password. Another way to connect to a database is to open a persistent connection. To do this, use the mysql_pconnectfunction and pass it the same arguments as mysql_connect. Why open a persistent connection? When you call mysql_pconnect, instead of going out and opening a connection to the database, it sees if one is already open, if it is, the script will use it. Also, when the script has finished executing, the connection to the database will not automatically be closed like it is when using mysql_connect. This way the connection can be used later on. Using a persistent connection is a good idea if your scripts constantly need to connect to the database.
After we have opened a connection to the database, we then select a database.
mysql_select_db("database_name") or die("Can't select database!");
This will try to select the database named “database_name” (for your own code change it to the name of your database). If it can’t select the database, it will output and error. Once you’re actually connected to a database, you will want to query a table in the database to get whatever you want done. A query looks like this:
mysql_query("Some query");
Common queries are SELECTand INSERT For full documentation go to the mysql web site ( http://www.mysql.com ). Another common php function is mysql_num_rows; if it isn’t obvious this gets the number of rows from a query. Here is an example of how it can be used with mysql_query:
<?php
$result= mysql_query("SELECT * FROM some_table");
$number_of_rows= @mysql_num_rows($result);
if ($number_of_rows == 0)
{
echo "Sorry there are no rows";
}
else {
echo "Yes! we found some rows!";
}
?>
Now you may be wondering why I put the @ sign before mysql_num_rows. In php, the @ sign suppress errors; I put it in front of mysql_num_rows so that if there are no rows, MySQL will not output a bunch of errors. So when would mysql_num_rows be useful? Well, you could use it for an authentication script which searchs the database for a username and password and if it doesn’t find any (i.e. if no rows are returned), it tells the user that the username, or password, are not correct.
Another really useful function is mysql_fetch_array, because it gets the rows and puts them in an array that contains the name of the rows. That way instead of having to access each row by number you can do it by name! For example, let’s say that our database looked like this:
| User | Password |
| John | afasdfadsfdsf |
| Billy | tla;jrjealjwqsldajf |
| Mitch | pqrtupipripewir |
We would use the following code to get the users’ names and output them:
<?php
echo "The users in this database are: <br>";
$result= mysql_query("SELECT * FROM some_table");
while ($row= mysql_fetch_array($result))
{
$username= $row["User"];
echo "$username<br>";
}
?>
This will output all the usernames in a database; you can add error checking if you like. The while statement is read “while there are rows that satisfy the query, put the contents of the row from the column ‘User’ into the variable ‘username,’ and print the usernames (each on a new line) to an HTML page.”
Now let’s cover a couple of functions that actually work with the database. The first is mysql_create_db, don’t you just love how the functions are named you can figure out what they do just by looking at the function name, this one obviously creates a database. Here’s how to use it:
<?php
echo "I am going to try to create a database...<br>";
if (mysql_create_db("test_database"))
{
echo "Hooray, I've created the database!<br>";
}
else {
echo "Darn couldn't create the database! because: ";
echo "mysql_error() <br>";
}
?>
You can see I used a new function, mysql_error, you don’t really need to know too much about it, all it does is return the error string sent by MySQL. Now since we learned how to create a database, how’s about we learn to delete one. To do that use the mysql_drop_db, here is how to use it:
<?php
echo "I am going to try to delete a database...<br>";
$result= mysql_drop_db("test_database");
if (!$result)
{
echo "Darn couldn't I couldn't delete the database!<br>";
}
else {
echo "Hooray, I've deleted the database<br>";
}
?>
You can see that the syntax is very similar to that of mysql_create_db, just pop the name of the database you want to delete into the function.
The next two items aren’t functions, rather they are queries that you can use to manage an existing table. The following query will insert data into a database:
<?php
echo "I am going to try to insert data into a table...<br>";
$result= mysql_query("INSERT INTO test_database (username, password) VALUES
(Rahim, adfjaldadfsdaf)");
if (!$result)
{
echo "Darn couldn't I couldn't delete the database!<br>";
}
else {
echo "Hooray, I've deleted the database<br>";
}
?>
This query should be pretty obvious, it inserts the data defined in between the parentheses into the rows. Just a little note to remember, the order in which you write out the column names is the order your data will be entered (i.e. a row with the contents Rahim will be entered under username, not password since we wrote username then pasword, if it was reveresd Rahim would be put under password).
The next query we’ve already gone over, I’m just going to add to it; after I’m done you should be able to use it to help create a simple search engine (upcomming tutorial)! For the sake of brevity I’ll remove all the extra php stuff and just show you the “meat” of the code.
$result= mysql_query("SELECT name FROM some_table WHERE name=Joe AND
lastname=Sixpack OR lastname=Becker ORDER BY lastname LIMIT 20");
Now I know that looks like a long query, but it’s not really all that bad. What it’s pretty much saying is: “Get me the name from some_table where the name is Joe and the lastname is Sixpack or Becker, oh and by the way while your at it, put it in alphabetical order by the lastname; oh and one last thing, just get the first 20 results please.” MySQL has lots of other filters that you can add on to the SELECT statement, I highly suggest you download the MySQL documentation and give it a perusing.
Powered by WP Robot