'MYSQL'カテゴリーのアーカイブ

PHPのMySQLチュートリアル

公開:2010年10月14日
タグ:
YouTubeのプレビュー画像

Rasonableロッキー

ダバオ、フィリピンに拠点を置くフィリピンのシニアPHPプログラマー、Web開発者とウェブマスター。 のJoomla、ワードプレス、Soholaunch、osCommerceのは、Drupal、ソーシャルメディアサイト、等の専門家

投稿 - ウェブサイト

 

'MYSQL'カテゴリーのアーカイブ

PHPのMySQLチュートリアル

公開:2010年10月14日
タグ:

これまでに学習します唯一のデータベース管理プログラムのインターネットホストのクライアントは、私のSQLです。 ので、多数のワールドワイドウェブのホストは、MySQLを提供している理由は、おそらくさらに説明する。 他のDMSのMySQLと頻繁には、SQL言語を使用し、ちょうど単一億ドルは今年、Sun Microsystemsによって買収された。

オープンソースソフトウェアのプログラム

MySQLの最強利点の人は、データベース管理技術は、オープンサプライプログラミングに基づいていることです。 これは、しかし、それはフリーウェアと見なされるべきであるという意味ではありません。 いいえ、そこに特許を取得した関数の数は、このプログラムに残っているため、それが使用するために現金がか​​かります。 しかし、オープン、電源、コンピュータソフトウェアのMySQLとしてそれを構築することにより、彼らが合うようにDBMSを変更するに 、ユーザーの自由の確実性を可能にします。 General Public Licenseの下でライセンスのMySQLは、オープンの電源コードを持っており、ソフトウェア·プログラムは、ライセンスは、彼らにこのように、ソフトウェアパッケージをリソース·コードを表示、変更および改善する権利を与える顧客に配布されている。 これは、MySQLがそう非常によく知られているであることが判明した理由の人です。

迅速なアップデートとフレンドリーな人

Oracleなどの他のデータベース管理システムがアップデートに低速である場合 、MySQL めったに彼らの顧客が待ってみましょうはありません。 新しいアップグレード版以上頻繁に出てくると、それはMySQLのように見えるプライ​​マリサーバのデータベースとして初期位置は、その場所を発見しました。 知られており、ちょうどネットのサーバーに適した手術方法であることを起こるLinuxの動作プログラムで主に使用し、MySQLはまた、迅速かつ信頼性が高くなります。

cPanelの、phpMyAdminはMySQLの

データベースを利用する初心者のプラットフォームの優れた例は、コントロールパネルの多くのインターネットホストは、cPanelの 、を利用しているされています。 人はデータベースを作成するためにビデオチュートリアルへのアクセス権を持っていますが、phpMyAdminの機能は、多くのMySQLのタスクを管理するユーザーに視覚的援助を提供していますだけではなく。 さらに、MySQLの存在は、人は彼/彼女のWebページの動的なアプリケーションを開発することができ、PHPスクリプトを提供するために、多数の単語·ワイド·ウェブのホストを可能にする

Rasonableロッキー

ダバオ、フィリピンに拠点を置くフィリピンのシニアPHPプログラマー、Web開発者とウェブマスター。 のJoomla、ワードプレス、Soholaunch、osCommerceのは、Drupal、ソーシャルメディアサイト、等の専門家

投稿 - ウェブサイト

 

'MYSQL'カテゴリーのアーカイブ

PHPのMySQLチュートリアル

公開:2010年10月14日
タグ:

1。)によってCCCA IDXのWebデザイン

ccca PHPと MySQLに基づくコンテンツ管理システムです。 すべての強力かつシンプルなCMS。 包括的な機能を提供します。 価格は、小さな会社のための合理的であると思われる。 簡単にインストールでき、ユーザーフレンドリー。 のみすべての利用可能なIDXのWebデザインのクライアント。 IDXのWebデザインに連絡して見積もり依頼

2。) Joomlaのウィルコヤンセン

joomla-s-webtreatsetc-128 Webサイトや強力なオンラインアプリケーションを構築することができます賞を受賞したコンテンツ管理システム(CMS)、。 その使いやすさと拡張性を含む多くの側面が、Joomlaの最も人気のあるWebサイトのソフトウェアが利用可能になっています。 すべてのベスト、Joomlaのは誰にでも自由に利用できるオープンソースのソリューションです。

3) ワードプレスによってライアンBOREN

wordpress-logo 美学、Web標準、ユーザビリティを中心とした最先端のパブリッシングプラットフォーム。WordPressは同時に自由で貴重でもあります。
もっと単純に、WordPressは 、あなたのブログソフトウェアで動作するようにしたいときに使用するものです、それを戦わない。

4) Soholaunch

soholaunch あなたは、構築、保守、およびあなたの個人的なまたはビジネスウェブサイトを管理するためのウェブサイト作成ツールを使いやすい。 それは簡単に、オンラインショッピングカートの注文を取るフォームを作成し、世界のどのコンピュータからでもサイトのページを編集できるように、あなたのウェブサイトから右に実行されます!

5。) Drupalの

drupal-s-webtreatsetc-128 ユーザーの個人やコミュニティが簡単に公開することができますフリーソフトウェアパッケージは、管理、およびウェブサイト上の多種多様なコンテンツを整理します。 人や組織は数万にはDrupalを使用して、別のWebサイトのパワースコアに

Rasonableロッキー

ダバオ、フィリピンに拠点を置くフィリピンのシニアPHPプログラマー、Web開発者とウェブマスター。 のJoomla、ワードプレス、Soholaunch、osCommerceのは、Drupal、ソーシャルメディアサイト、等の専門家

投稿 - ウェブサイト

 

'MYSQL'カテゴリーのアーカイブ

PHPのMySQLチュートリアル

公開:2010年10月14日
タグ:

我々が最初にやるべきことは、データベースに接続されています。

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.

Rocky Rasonable

A filipino Senior PHP Programmer, Web Developer and Webmaster based in Davao, Philippines. Expert in Joomla, WordPress, Soholaunch, Oscommerce, Drupal, Social Media Sites, and etc.

More Posts - Website

 

Translator

English flagItalian flagKorean flagChinese (Simplified) flagChinese (Traditional) flagPortuguese flagGerman flagFrench flagSpanish flagJapanese flag
Arabic flagGreek flagDutch flagBulgarian flagCzech flagCroatian flagDanish flagFinnish flagHindi flagPolish flag
Romanian flagSwedish flagNorwegian flagCatalan flagFilipino flagHebrew flagIndonesian flagLatvian flagLithuanian flagSerbian flag
Slovak flagSlovenian flagUkrainian flagVietnamese flagAlbanian flagEstonian flagGalician flagMaltese flagThai flagTurkish flag
Hungarian flag         

My Partners

alexa.comのレビューrockyrasonable.com

Hostgatorの
Hostgatorの templateplazza elegantthemes rockettheme TopPhilippineWebsites.com プログラミングのブログロールセンター

Tags

Adobe Flash Playerの入手 Plugin by wpburn.com wordpress themes

Powered by WP Robot