sponsor

Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts

Tuesday, January 20, 2009

my article in google translate

I just opened my website is a long time, and in fact one of the articles there have been translated from English into English. I already have other people who use google translate to translate the page. Original title is cara instalasi xampp
And this is a version of the translation in the English language

XAMPP is an installation package for PHP, Apache and MySQL. By using XAMPP, we do not need to be bothered to install the software that third separately.XAMPP can be downloaded at http://www.apachefriends.org/en/index.html.Here is how to install XAMPP.

  1. Run the file xampp-Win32-1.4.12-installer.exe (or other version)

  2. Then will appear to select a language option during installation to run.Please select the English language or English, unless you take another language. In this example I choose the English language because I love English.Memilih bahasa

  3. The installation will start. Click forward to get started.Mulai Instalasi

  4. Akan appear license software. Please read it if you want, but I prefer not to read it because too many. Click I Agree to continue.Lisensi Software

  5. Then please select your location to install XAMPP. Then click install

  6. Wait a while until the installation is complete.Tunggu sebentar

  7. Installation finishedinstalasi selesai

  8. Until this stage, we have installed XAMPP. That means we have finished installing PHP, Apache and MYSQL. The next step is to run servicenya.

  9. Run the XAMPP Control Panel on the desktop. Or you can also run the XAMPP Control Panel from the Start menu -> All Programs -> apachefriends -> xampp -> xampp control panel.xampp control panel

  10. Turn on Apache and Mysql by clicking the Start button. Open your web browser, and type http://localhost. If it looks like below, then apache is installed correctly.

  11. As information only, document property XAMPP root folder is located on the E: \ Program Files \ apachefriends \ xampp \ htdocs. This is because I install XAMPP folder on the E: \ Program Files \ apachefriends.


you can view the complete article in english here

Wednesday, December 31, 2008

calculate age with mysql

you can use mysql to determine how many years old of your employee is. This is just compute the difference in the year part of the current date and the birth date, then subtract one if the current date occurs earlier in the calendar year than the birth date. The following query shows, for each employee, name, birth date, the current date, and the age in the years. In this example I use table employee which has fields : employee_id, employee_name, birthdate

SELECT employee_id, employee_name, birthdate, CURDATE(),
(YEAR(CURDATE())-YEAR(birthdate))
- (RIGHT(CURDATE(),5)<RIGHT(birthdate,5))
AS age
FROM employee

Monday, November 5, 2007

SELECT Syntax MySQL


SELECT
[ALL | DISTINCT | DISTINCTROW ]
[HIGH_PRIORITY]
[STRAIGHT_JOIN]
[SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
[SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS]
select_expr, ...
[FROM table_references
[WHERE where_condition]
[GROUP BY {col_name | expr | position}
[ASC | DESC], ... [WITH ROLLUP]]
[HAVING where_condition]
[ORDER BY {col_name | expr | position}
[ASC | DESC], ...]
[LIMIT {[offset,] row_count | row_count OFFSET offset}]
[PROCEDURE procedure_name(argument_list)]
[INTO OUTFILE 'file_name' export_options
| INTO DUMPFILE 'file_name'
| INTO var_name [, var_name]]
[FOR UPDATE | LOCK IN SHARE MODE]]


SELECT is used to retrieve rows selected from one or more tables, and can include UNION statements and subqueries. See Section 12.2.7.3, “UNION Syntax”, and Section 12.2.8, “Subquery Syntax”.

The most commonly used clauses of SELECT statements are these:

*

Each select_expr indicates a column that you want to retrieve. There must be at least one select_expr.
*

table_references indicates the table or tables from which to retrieve rows. Its syntax is described in Section 12.2.7.1, “JOIN Syntax”.
*

The WHERE clause, if given, indicates the condition or conditions that rows must satisfy to be selected. where_condition is an expression that evaluates to true for each row to be selected. The statement selects all rows if there is no WHERE clause.

In the WHERE clause, you can use any of the functions and operators that MySQL supports, except for aggregate (summary) functions. See Chapter 11, Functions and Operators.

SELECT can also be used to retrieve rows computed without reference to any table.

For example:

mysql> SELECT 1 + 1;
-> 2

You are allowed to specify DUAL as a dummy table name in situations where no tables are referenced:

mysql> SELECT 1 + 1 FROM DUAL;
-> 2

DUAL is purely for the convenience of people who require that all SELECT statements should have FROM and possibly other clauses. MySQL may ignore the clauses. MySQL does not require FROM DUAL if no tables are referenced.

In general, clauses used must be given in exactly the order shown in the syntax description. For example, a HAVING clause must come after any GROUP BY clause and before any ORDER BY clause. The exception is that the INTO clause can appear either as shown in the syntax description or immediately preceding the FROM clause.

*

A select_expr can be given an alias using AS alias_name. The alias is used as the expression's column name and can be used in GROUP BY, ORDER BY, or HAVING clauses. For example:

SELECT CONCAT(last_name,', ',first_name) AS full_name
FROM mytable ORDER BY full_name;

The AS keyword is optional when aliasing a select_expr. The preceding example could have been written like this:

SELECT CONCAT(last_name,', ',first_name) full_name
FROM mytable ORDER BY full_name;

However, because the AS is optional, a subtle problem can occur if you forget the comma between two select_expr expressions: MySQL interprets the second as an alias name. For example, in the following statement, columnb is treated as an alias name:

SELECT columna columnb FROM mytable;

For this reason, it is good practice to be in the habit of using AS explicitly when specifying column aliases.
*

It is not allowable to use a column alias in a WHERE clause, because the column value might not yet be determined when the WHERE clause is executed. See Section B.1.5.4, “Problems with Column Aliases”.
*

The FROM table_references clause indicates the table or tables from which to retrieve rows. If you name more than one table, you are performing a join. For information on join syntax, see Section 12.2.7.1, “JOIN Syntax”. For each table specified, you can optionally specify an alias.

tbl_name [[AS] alias] [index_hint]

The use of index hints provides the optimizer with information about how to choose indexes during query processing. For a description of the syntax for specifying these hints, see Section 12.2.7.2, “Index Hint Syntax”.

You can use SET max_seeks_for_key=value as an alternative way to force MySQL to prefer key scans instead of table scans. See Section 5.2.3, “System Variables”.
*

You can refer to a table within the default database as tbl_name, or as db_name.tbl_name to specify a database explicitly. You can refer to a column as col_name, tbl_name.col_name, or db_name.tbl_name.col_name. You need not specify a tbl_name or db_name.tbl_name prefix for a column reference unless the reference would be ambiguous. See Section 8.2.1, “Identifier Qualifiers”, for examples of ambiguity that require the more explicit column reference forms.
*

A table reference can be aliased using tbl_name AS alias_name or tbl_name alias_name:

SELECT t1.name, t2.salary FROM employee AS t1, info AS t2
WHERE t1.name = t2.name;

SELECT t1.name, t2.salary FROM employee t1, info t2
WHERE t1.name = t2.name;

*

Columns selected for output can be referred to in ORDER BY and GROUP BY clauses using column names, column aliases, or column positions. Column positions are integers and begin with 1:

SELECT college, region, seed FROM tournament
ORDER BY region, seed;

SELECT college, region AS r, seed AS s FROM tournament
ORDER BY r, s;

SELECT college, region, seed FROM tournament
ORDER BY 2, 3;

To sort in reverse order, add the DESC (descending) keyword to the name of the column in the ORDER BY clause that you are sorting by. The default is ascending order; this can be specified explicitly using the ASC keyword.

If ORDER BY occurs within a subquery and also is applied in the outer query, the outermost ORDER BY takes precedence. For example, results for the following statement are sorted in descending order, not ascending order:

(SELECT ... ORDER BY a) ORDER BY a DESC;

Use of column positions is deprecated because the syntax has been removed from the SQL standard.
*

If you use GROUP BY, output rows are sorted according to the GROUP BY columns as if you had an ORDER BY for the same columns. To avoid the overhead of sorting that GROUP BY produces, add ORDER BY NULL:

SELECT a, COUNT(b) FROM test_table GROUP BY a ORDER BY NULL;

*

MySQL extends the GROUP BY clause so that you can also specify ASC and DESC after columns named in the clause:

SELECT a, COUNT(b) FROM test_table GROUP BY a DESC;

*

MySQL extends the use of GROUP BY to allow selecting fields that are not mentioned in the GROUP BY clause. If you are not getting the results that you expect from your query, please read the description of GROUP BY found in Section 11.11, “Functions and Modifiers for Use with GROUP BY Clauses”.
*

GROUP BY allows a WITH ROLLUP modifier. See Section 11.11.2, “GROUP BY Modifiers”.
*

The HAVING clause is applied nearly last, just before items are sent to the client, with no optimization. (LIMIT is applied after HAVING.)

A HAVING clause can refer to any column or alias named in a select_expr in the SELECT list or in outer subqueries, and to aggregate functions. However, the SQL standard requires that HAVING must reference only columns in the GROUP BY clause or columns used in aggregate functions. To accommodate both standard SQL and the MySQL-specific behavior of being able to refer columns in the SELECT list, MySQL 5.0.2 and up allows HAVING to refer to columns in the SELECT list, columns in the GROUP BY clause, columns in outer subqueries, and to aggregate functions.

For example, the following statement works in MySQL 5.0.2 but produces an error for earlier versions:

mysql> SELECT COUNT(*) FROM t GROUP BY col1 HAVING col1 = 2;

If the HAVING clause refers to a column that is ambiguous, a warning occurs. In the following statement, col2 is ambiguous because it is used as both an alias and a column name:

SELECT COUNT(col1) AS col2 FROM t GROUP BY col2 HAVING col2 = 2;

Preference is given to standard SQL behavior, so if a HAVING column name is used both in GROUP BY and as an aliased column in the output column list, preference is given to the column in the GROUP BY column.
*

Do not use HAVING for items that should be in the WHERE clause. For example, do not write the following:

SELECT col_name FROM tbl_name HAVING col_name > 0;

Write this instead:

SELECT col_name FROM tbl_name WHERE col_name > 0;

*

The HAVING clause can refer to aggregate functions, which the WHERE clause cannot:

SELECT user, MAX(salary) FROM users
GROUP BY user HAVING MAX(salary) > 10;

(This did not work in some older versions of MySQL.)
*

MySQL allows duplicate column names. That is, there can be more than one select_expr with the same name. This is an extension to standard SQL. Because MySQL also allows GROUP BY and HAVING to refer to select_expr values, this can result in an ambiguity:

SELECT 12 AS a, a FROM t GROUP BY a;

In that statement, both columns have the name a. To ensure that the correct column is used for grouping, use different names for each select_expr.
*

MySQL resolves unqualified column or alias references in ORDER BY clauses by searching in the select_expr values, then in the columns of the tables in the FROM clause. For GROUP BY or HAVING clauses, it searches the FROM clause before searching in the select_expr values. (For GROUP BY and HAVING, this differs from the pre-MySQL 5.0 behavior that used the same rules as for ORDER BY.)
*

The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be non-negative integer constants (except when using prepared statements).

With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):

SELECT * FROM tbl LIMIT 5,10; # Retrieve rows 6-15

To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter. This statement retrieves all rows from the 96th row to the last:

SELECT * FROM tbl LIMIT 95,18446744073709551615;

With one argument, the value specifies the number of rows to return from the beginning of the result set:

SELECT * FROM tbl LIMIT 5; # Retrieve first 5 rows

In other words, LIMIT row_count is equivalent to LIMIT 0, row_count.

For prepared statements, you can use placeholders (supported as of MySQL version 5.0.7). The following statements will return one row from the tbl table:

SET @a=1;
PREPARE STMT FROM 'SELECT * FROM tbl LIMIT ?';
EXECUTE STMT USING @a;

The following statements will return the second to sixth row from the tbl table:

SET @skip=1; SET @numrows=5;
PREPARE STMT FROM 'SELECT * FROM tbl LIMIT ?, ?';
EXECUTE STMT USING @skip, @numrows;

For compatibility with PostgreSQL, MySQL also supports the LIMIT row_count OFFSET offset syntax.

If LIMIT occurs within a subquery and also is applied in the outer query, the outermost LIMIT takes precedence. For example, the following statement produces two rows, not one:

(SELECT ... LIMIT 1) LIMIT 2;

*

The SELECT ... INTO OUTFILE 'file_name' form of SELECT writes the selected rows to a file. The file is created on the server host, so you must have the FILE privilege to use this syntax. file_name cannot be an existing file, which among other things prevents files such as /etc/passwd and database tables from being destroyed. As of MySQL 5.0.19, the character_set_filesystem system variable controls the interpretation of the filename.

The SELECT ... INTO OUTFILE statement is intended primarily to let you very quickly dump a table to a text file on the server machine. If you want to create the resulting file on some client host other than the server host, you cannot use SELECT ... INTO OUTFILE. In that case, you should instead use a command such as mysql -e "SELECT ..." > file_name to generate the file on the client host.

SELECT ... INTO OUTFILE is the complement of LOAD DATA INFILE; the syntax for the export_options part of the statement consists of the same FIELDS and LINES clauses that are used with the LOAD DATA INFILE statement. See Section 12.2.5, “LOAD DATA INFILE Syntax”.

FIELDS ESCAPED BY controls how to write special characters. If the FIELDS ESCAPED BY character is not empty, it is used as a prefix that precedes following characters on output:
o

The FIELDS ESCAPED BY character
o

The FIELDS [OPTIONALLY] ENCLOSED BY character
o

The first character of the FIELDS TERMINATED BY and LINES TERMINATED BY values
o

ASCII NUL (the zero-valued byte; what is actually written following the escape character is ASCII “0”, not a zero-valued byte)

The FIELDS TERMINATED BY, ENCLOSED BY, ESCAPED BY, or LINES TERMINATED BY characters must be escaped so that you can read the file back in reliably. ASCII NUL is escaped to make it easier to view with some pagers.

The resulting file does not have to conform to SQL syntax, so nothing else need be escaped.

If the FIELDS ESCAPED BY character is empty, no characters are escaped and NULL is output as NULL, not \N. It is probably not a good idea to specify an empty escape character, particularly if field values in your data contain any of the characters in the list just given.

Here is an example that produces a file in the comma-separated values (CSV) format used by many programs:

SELECT a,b,a+b INTO OUTFILE '/tmp/result.txt'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table;

*

If you use INTO DUMPFILE instead of INTO OUTFILE, MySQL writes only one row into the file, without any column or line termination and without performing any escape processing. This is useful if you want to store a BLOB value in a file.
*

The INTO clause can name a list of one or more variables, which can be user-defined variables, or parameters or local variables within a stored function or procedure body. The selected values are assigned to the variables. The number of variables must match the number of columns.

Within a stored routine, the variables can be routine parameters or local variables. See Section 18.2.7.3, “SELECT ... INTO Statement”.
*
Note

Any file created by INTO OUTFILE or INTO DUMPFILE is writable by all users on the server host. The reason for this is that the MySQL server cannot create a file that is owned by anyone other than the user under whose account it is running. (You should never run mysqld as root for this and other reasons.) The file thus must be world-writable so that you can manipulate its contents.
*

The SELECT syntax description at the beginning this section shows the INTO clause near the end of the statement. It is also possible to use INTO OUTFILE or INTO DUMPFILE immediately preceding the FROM clause.
*

A PROCEDURE clause names a procedure that should process the data in the result set. For an example, see Section 26.3.1, “Procedure Analyse”.
*

If you use FOR UPDATE with a storage engine that uses page or row locks, rows examined by the query are write-locked until the end of the current transaction. Using LOCK IN SHARE MODE sets a shared lock that allows other transactions to read the examined rows but not to update or delete them. See Section 13.2.10.5, “SELECT ... FOR UPDATE and SELECT ... LOCK IN SHARE MODE Locking Reads”.

Following the SELECT keyword, you can use a number of options that affect the operation of the statement.

The ALL, DISTINCT, and DISTINCTROW options specify whether duplicate rows should be returned. If none of these options are given, the default is ALL (all matching rows are returned). DISTINCT and DISTINCTROW are synonyms and specify removal of duplicate rows from the result set.

HIGH_PRIORITY, STRAIGHT_JOIN, and options beginning with SQL_ are MySQL extensions to standard SQL.

*

HIGH_PRIORITY gives the SELECT higher priority than a statement that updates a table. You should use this only for queries that are very fast and must be done at once. A SELECT HIGH_PRIORITY query that is issued while the table is locked for reading runs even if there is an update statement waiting for the table to be free. This affects only storage engines that use only table-level locking (MyISAM, MEMORY, MERGE).

HIGH_PRIORITY cannot be used with SELECT statements that are part of a UNION.
*

STRAIGHT_JOIN forces the optimizer to join the tables in the order in which they are listed in the FROM clause. You can use this to speed up a query if the optimizer joins the tables in non-optimal order. See Section 6.2.1, “Optimizing Queries with EXPLAIN”. STRAIGHT_JOIN also can be used in the table_references list. See Section 12.2.7.1, “JOIN Syntax”.
*

SQL_BIG_RESULT can be used with GROUP BY or DISTINCT to tell the optimizer that the result set has many rows. In this case, MySQL directly uses disk-based temporary tables if needed, and prefers sorting to using a temporary table with a key on the GROUP BY elements.
*

SQL_BUFFER_RESULT forces the result to be put into a temporary table. This helps MySQL free the table locks early and helps in cases where it takes a long time to send the result set to the client.
*

SQL_SMALL_RESULT can be used with GROUP BY or DISTINCT to tell the optimizer that the result set is small. In this case, MySQL uses fast temporary tables to store the resulting table instead of using sorting. This should not normally be needed.
*

SQL_CALC_FOUND_ROWS tells MySQL to calculate how many rows there would be in the result set, disregarding any LIMIT clause. The number of rows can then be retrieved with SELECT FOUND_ROWS(). See Section 11.10.3, “Information Functions”.
*

SQL_CACHE tells MySQL to store the query result in the query cache if you are using a query_cache_type value of 2 or DEMAND. For a query that uses UNION or subqueries, this option effects any SELECT in the query. See Section 6.5.4, “The MySQL Query Cache”.
*

SQL_NO_CACHE tells MySQL not to store the query result in the query cache. See Section 6.5.4, “The MySQL Query Cache”. For a query that uses UNION or subqueries, this option effects any SELECT in the query.

Friday, September 14, 2007

Cara Instalasi XAMPP

XAMPP merupakan sebuah paket instalasi untuk PHP, APACHE dan MySQL. Dengan menggunakan XAMPP, kita tidak perlu lagi repot menginstall ketiga software itu secara terpisah. XAMPP dapat di download di http://www.apachefriends.org/en/index.html. Berikut ini adalah cara menginstall XAMPP.

1. Jalankan file xampp-win32-1.4.12-installer.exe (atau versi lainnya)

2. Kemudian akan tampil pilihan untuk memilih bahasa ketika proses instalasi berjalan. Silakan pilih bahasa Indonesian atau English, kecuali anda menguasai bahasa lainnya. Pada contoh ini saya memilih bahasa Indonesian karena saya cinta bahasa Indonesia. Memilih bahasa

3. Proses instalasi akan dimulai. Klik Maju untuk memulainya. Mulai Instalasi


4. Akan muncul lisensi software. Silahkan membacanya jika anda mau, tetapi saya lebih suka untuk tidak membacanya karena terlalu banyak. Klik Saya Setuju untuk melanjutkan.Lisensi Software

5. Selanjutnya silakan anda pilih lokasi install untuk XAMPP. Kemudian klik install

6. Tunggu beberapa saat sampai proses instalasi selesai.Tunggu sebentar

7. Instalasi selesai

8. Sampai tahap ini, berarti kita sudah menginstal XAMPP. Itu berarti kita sudah selesai menginstall PHP, APACHE dan MYSQL. Langkah selanjutnya adalah menjalankan servicenya.

9. Jalankan XAMPP Control Panel yang ada di desktop. Atau anda juga dapat menjalankan XAMPP Control Panel dari menu Start -> All Programs -> apachefriends -> xampp -> xampp control panel. xampp control panel


10. Nyalakan Apache dan Mysql dengan mengklik tombol Start. Buka web browser anda, lalu ketikkan http://localhost. Jika tampilannya seperti di bawah ini, maka apache sudah terinstall dengan benar.


11. Sekedar informasi saja, document root milik XAMPP terletak pada folder E:\Program Files\apachefriends\xampp\htdocs. Hal ini disebabkan karena saya menginstall XAMPP pada folder E:\Program Files\apachefriends.

Thursday, September 13, 2007

PhpMyAdmin

Phpmyadmin adalah suatu aplikasi yang dibuat dengan bahasa pemrograman PHP yang ditujukan untuk pengelolaan basis data MySQL melalui Internet. Fungsi phpmyadmin sama dengan fungsi software lain seperti SQLYOG dan MySQLFront. Hanya saja PhpMyAdmin adalah free software. Sebelum mengikuti tutorial ini lebih lanjut, ada baiknya anda mendownload dulu phpmyadmin.

Cara Menggunakan Phpmyadmin

1. Pastikan Apache, PHP dan MySQL sudah terinstall di komputer Anda. Copy file phpMyAdmin-2.5.6.zip ke dalam folder di mana anda menyimpan file php (dalam Document Root)

2. Extract file tersebut sehingga akan terbentuk sebuah folder bernama phpMyAdmin-2.5.6

3. Bukalah web browser dan ketikkan http://localhost, lalu carilah folder tersebut.
Jika web browser anda menampilkan halaman sbb, maka anda harus mengatur / konfigurasi username dan password mysql di phpmyadmin terlebih dahulu.

4. Akan tetapi jika tampilannya sebagai berikut, berarti anda tidak perlu melakukan pengaturan / konfigurasi username dan password mysql di phpmyadmin

5. Jika tampilannya seperti pada gambar 3, maka anda harus melakukan konfigurasi username dan password mysqldi phpmyadmin. Caranya adalah buka folder phpMyAdmin-2.5.6 melalui windows explorer. Kemudian bukalah file config.inc.php (boleh menggunakan Dreamweaver maupun notepad).

6. Ubahlah beberapa settingan sbb :
di baris ke 69 : $cfg[’Servers’][$i][’host’] = ‘localhost’;
$cfg[’Servers’][$i][’host’] berisi host atau komputer tempat database mysql berada. Isi dengan localhost jika database mysql berada di komputer anda

Di baris ke-70 : $cfg[’Servers’][$i][’port’] = ‘’;
$cfg[’Servers’][$i][’port’] adalah port yang digunakan mysql. Kosongkan jika mysql anda menggunakan port standar (3306)

Di baris ke-83 : $cfg[’Servers’][$i][’user’] = ‘root’;
$cfg[’Servers’][$i][’user’] adalah user yang digunakan untuk koneksi ke mysql

Di baris ke-84 : $cfg[’Servers’][$i][’password’] = ‘’;
$cfg[’Servers’][$i][’password’] adalah password yang digunakan untuk koneksi ke mysql

Monday, August 20, 2007

Membuat Halaman Login Dengan PHP, MySQL, AJAX, Script.aculo.us dan Prototype.js (bag 2)

Oke, sekarang akan saya lanjutkan tutorial yang kedua. Saya anggap Anda sudah mendownload script.acyulo.us dan prototype.js. Kalo belum, silakan anda download lebih dahulu.
Silakan buka file login.php dan ubah menjadi sebagai berikut.
login.php


buat juga CSS nya dan simpan dengan nama style.css


sampai sejauh ini, kita udah membuat 2 buah file, yaitu login.php dan style.css, selanjutnya kita harus membuat satu file lagi yaitu ajax.php yang akan digunakan untuk mengecek login. Kita juga butuh sebuah database yang berisikan username dan password. Tunggu tutorial bagian ke-3 ya....

Thursday, August 16, 2007

Membuat Halaman Login Dengan PHP, MySQL, AJAX, Script.aculo.us dan Prototype.js (bag 1)

Dalam tutorial kali ini, saya akan menjelaskan bagaimana cara membuat halaman login dengan PHP, MySQL, AJAX, ScriptAculous dan Prototype.js. Untuk mengikuti tutorial ini, Anda sebaiknya sudah mengerti konsep webserver, PHP, dan database MySQL. Kalo belum, sebaiknya Anda mempelajarinya terlebih dahulu. Anda juga harus mengerti AJAX, ScriptAculous dan Prototype.js. Kalo belum mengerti, sebaiknya baca tutorialnya di sini dulu.

Oke, kita mulai saja ya... Pertama Anda harus menyiapkan sebuah halaman HTML untuk login. Kita beri nama "login.php".


saya rasa untuk tag HTML tidak perlu saya jelaskan lagi. Itu adalah tag HTML untuk membuat halaman login yang terdiri dari textbox username dan password. Dalam HTML di atas juga saya buatkan sebuah div untuk menampung hasil error ketika proses login berlangsung. Untuk mengikuti tutorial login bagian ke2, sebaiknya Anda download dulu library prototype.js dan scriptaculous. Tunggu tutorial bagian keduanya ya....

Sunday, July 22, 2007

How To Connect PHP - MySQL

In this post, I will explain you about PHP and MySQL. You can use PHP with MySQL database. You only need a simple script to connect PHP- MySQL.
1. mysql_connect() -- Open a connection to a MySQL Server
This function need several parameters. For example :
mysql_connect("localhost","root","12345")
notes : localhost --> the mysql server name
root --> the mysql username
12345 --> the mysql password

example : $link = mysql_connect("localhost", "mysql_user", "mysql_password")
or die("Could not connect");

2. mysql_select_db() --> Select a MySQL database
You need database name for this function
example : mysql_select_db("mysql")
notes : mysql is the database name is mysql database

3. mysql_query() --> Send a MySQL query
example : $result = mysql_query("SELECT * WHERE user='jhon'")
or die("Invalid query");
notes : SELECT * WHERE user='jhon' is query for mysql.