A total of 3 files
incdb.php Database Connection
index.php Home
insettodb.php Database Operations
Database Lguestbook built-in table
Copy CodeThe code is as follows:
CREATE TABLE ' Intd ' (
' id ' int (one) not NULL auto_increment,
' Name ' varchar (255) Character Set UTF8 collate utf8_bin not NULL,
' Text ' text character set UTF8 collate utf8_bin not NULL,
' DateTime ' datetime not NULL,
PRIMARY KEY (' id ')
) Engine=myisam DEFAULT charset=gb2312 auto_increment=11; This sentence refers to the following extension content;
incdb.php Database Connection
Copy CodeThe code is as follows:
$link =mysql_connect (' localhost ', ' root ', ' root ');
if (! $link)
{
Die (" Error: 1! ");
}
if (!mysql_select_db (' Guestbook ', $link))
{
Die (" Error: 2! ");
}
?>
index.php Code
Copy CodeThe code is as follows:
Include ("incdb.php");
$result =mysql_query ("SELECT * from Intd", $link);
$row =mysql_fetch_row ($result);
while ($row)
{
echo "ID:". $row [0]. "Name:". $row [1]. "Time:". $row [3]. "
";
Echo $row [2];
echo "
";
$row =mysql_fetch_row ($result);
}
Mysql_close ($link);
?>
Insettodb.php's Code:
Copy CodeThe code is as follows:
Include ("incdb.php");
$name =addslashes ($_post[' name ');
$text =addslashes ($_post[' text ');
$sql = "INSERT into ' intd ' (' id ', ' name ', ' Text ', ' datetime ') VALUES (NULL, ' $name ', ' $text ', now ());";
$sql = "INSERT into ' intd ' (, ' name ', ' Text ', ' datetime ') VALUES (, ' $name ', ' $text ', Now ())";
if (mysql_query ($sql, $link))
{
echo "The message was successful! ";
echo " ";
}
Else
echo "Message failed! ";
Mysql_close ($link);
?>
Extended content explained:
The difference between MySQL engine/type type Innodb/myisam/merge/bdb/heap
See MySQL reference manual There are a variety of database storage engines when you discover create TABLE:
TYPE = {BDB | HEAP | ISAM | InnoDB | MERGE | Mrg_myisam | MYISAM}
On the internet, it is said that MyISAM, InnoDB two kinds of engines commonly used
The difference is as follows [I don't know if it's accurate]:
Advanced Processing:
MyISAM types do not support advanced processing such as transaction processing, and InnoDB type support.
Execution Speed:
Tables of the MyISAM type emphasize performance, which is performed more quickly than the InnoDB type.
Transfer value:
Binary data files of type MyISAM can be migrated in different operating systems. That is, it can be copied directly from the Windows system to a Linux system.
Find an official, accurate explanation today.
· MyISAM: The default MySQL plug-in storage engine, which is one of the most commonly used storage engines in the Web, data warehousing, and other application environments. Note that it is easy to change the default storage engine of the MySQL server by changing the storage_engine configuration variable.
· InnoDB: For transactional applications, with many features, including acid transaction support.
· BDB: An alternative to the INNODB transaction engine that supports commit, rollback, and other transactional features.
· Memory: Keep all your data in RAM and provide extremely fast access in environments where you need to quickly find references and other similar data.
· Merge: Allows a MySQL DBA or developer to logically group together a series of equivalent MyISAM tables and reference them as 1 objects. Ideal for VLDB environments such as data warehousing.
· Archive: Provides the perfect solution for storing and retrieving large amounts of historically, archived, or security audit information that is rarely referenced.
· Federated: The ability to link multiple separate MySQL servers to create a logical database from multiple physical servers. Ideal for distributed environments or data mart environments.
· Cluster/ndb:mysql's clustered database engine, especially suitable for applications with high performance lookup requirements, also requires the highest uptime and availability.
· Other: The other storage engines include CSV (referencing a comma-delimited file used as a database table), blackhole (for temporary suppression of application input to the database), and the example engine, which can help with the quick creation of a custom plug-in storage engine.
Keep in mind that you don't have to use the same storage engine for the entire server or scenario, and you can use a different storage engine for each table in the scenario, which is important.
http://www.bkjia.com/PHPjc/320864.html www.bkjia.com true http://www.bkjia.com/PHPjc/320864.html techarticle Total 3 files incdb.php database connection index.php home insettodb.php database operations database Lguestbook the built-in table copy code code is as follows: CREATE table ' Intd ' (' id ' int (one) NO T ...