search
Homephp教程php手册PHP和MYSQL数据库合理且有效的结合在一起

PHP和MYSQL数据库合理且有效的结合在一起

Jun 13, 2016 am 11:01 AM
mysqlphpReasonableandWilldatabaseefficientofcombine

将PHP和MYSQL合理且有效的结合在一起可以制作出精致的数据库网站。MYSQL是一种小型的,紧密的数据服务器,支持标准SQL。它在UNIX和WINDOWS环境下都能够使用。

PHP和MYSQL都是免费的开放源码。它们的结合可以在WINDOWS中发展,在UNIX中做服务。PHP也支持其他一些数据库包括PostgreSQL.

下面有一个例子:

首先你已经安装了PHP及MYSQL. 这个简单的脚本例子是从数据库中读取数据然后显示出来。

<html><body><?php $db = mysql_connect("localhost", "root"); mysql_select_db("mydb", $db); $result = mysql_query("SELECT * FROM books",$db); echo "Title: ".mysql_result($result,0,"title")."<br>n"; echo "Author: ".mysql_result($result,0,"author")."<br>n"; echo "Price: ".mysql_result($result,0,"price")."<br>n"; ?></body></html>

函数mysql_connect()是指在指定的主机上通过用户名(也可通过指定密码)连接一个MYSQL服务器。变量 $db 是用来提交这个连接。.

mysql_select_db() 指定数据库用在后面的疑问。函数 mysql_query() 是发送 SQL 疑问到 MySQL 进行执行 , 结果返回并存储在变量 $result 中.

最后 mysql_result() 函数是得出结果。


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.