search
Homephp教程php手册也谈 PHP 和 MYSQL

也谈 PHP 和 MYSQL

Jun 13, 2016 pm 12:41 PM
mysqlphpCanReasonableandWilldatabaseefficientofcombine

将PHP和MYSQL合理且有效的结合在一起可以制作出精致的数据库网站。MYSQL是一种小型的,紧密的数据服务器,支持标准SQL。它在UNIX和WINDOWS环境下都能够使用。
  PHP和MYSQL都是免费的开放源码。它们的结合可以在WINDOWS中发展,在UNIX中做服务。PHP也支持其他一些数据库包括PostgreSQL.

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




$db = mysql_connect("localhost", "root");
mysql_select_db("mydb", $db);
$result = mysql_query("SELECT * FROM books",$db);
echo "Title: ".mysql_result($result,0,"title")."
\n";
echo "Author: ".mysql_result($result,0,"author")."
\n";
echo "Price: ".mysql_result($result,0,"price")."
\n";

?>



函数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 Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.