search
Homephp教程php手册php mysql数据库操作教程

php mysql数据库操作教程

Jun 13, 2016 am 10:08 AM
mysqlphponeaboutExampleoperateTutorialdatabaseof

php mysql数据库操作教程 本教程讲了三个实例都是关于php操作mysql数据库的教程,一是连接mysql数据库,二是查询数据库字段名字,三是查询数据库记录。

php教程 mysql教程数据库教程操作教程
本教程讲了三个实例都是关于php操作mysql数据库的教程,一是连接mysql数据库,二是查询数据库字段名字,三是查询数据库记录。
*/
//连接mysql数据库

$link = mysql_connect("localhost", "mysql_user", "mysql_password")
        or die("could not connect: " . mysql_error());
    print ("connected successfully");
    mysql_close($link);


 
//查询mysql字段名

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');

$fields = mysql_list_fields("database1", "table1", $link);
$columns = mysql_num_fields($fields);

for ($i = 0; $i     echo mysql_field_name($fields, $i) . "n";
}

//查询数据

$conn=mysql_connect("localhost","phpdb","phpdb")
        or die("不能连接数据库服务器: ".mysql_error());
mysql_select_db("test",$conn) or die ("不能选择数据库: ".mysql_error()); 
$result = mysql_query("select * from user",$conn);
while($row=mysql_fetch_array($result)){ 
print "name:".$row[1]; 
print " address:".$row[3]; 
print " tel:".$row[4]; 
print " email:".$row[5];
echo

"
";
}

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment