php中数据库连接代码
<?php //连接数据库 $link=mysql_connect("127.0.0.1","root","123456"); //选择数据库 mysql_select_db("userdb",$link); //sql语句 $sql="select * from userInfo"; //设置查询出来的结果编码集也为utf8 mysql_query("set names utf8"); //执行sql语句 $rs=mysql_query($sql); //返回受影响的行数 $num=mysql_num_rows($rs); ?> <table border="1" align="center"> <tr> <td>姓名</td> <td>密码</td> </tr> <?php //循环遍历 for($i=0;$i<mysql_num_rows($rs);$i++){ //将结果集转化为数组 $list=mysql_fetch_array($rs); ?> <tr> <td><?php echo $list["name"]?></td> <td><?php echo $list["pwd"]?></td> </tr> <?php } ?>
以上就是数据库连接代码的内容,更多相关内容请关注PHP中文网(www.php.cn)!
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
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article
Assassin's Creed Shadows: Seashell Riddle Solution
3 weeks agoByDDD
What's New in Windows 11 KB5054979 & How to Fix Update Issues
2 weeks agoByDDD
Assassin's Creed Shadows - How To Find The Blacksmith And Unlock Weapon And Armour Customisation
1 months agoByDDD
Where to find the Crane Control Keycard in Atomfall
3 weeks agoByDDD
Roblox: Dead Rails - How To Complete Every Challenge
3 weeks agoByDDD

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Notepad++7.3.1
Easy-to-use and free code editor