PHP database operation mysqli

WBOY
Release: 2016-07-29 09:01:47
Original
1174 people have browsed it

Database link

$server = "127.0.0.1"; $username = "username"; $pass = "password"; $con = new mysqli($server,$username,$pass[,$db_name]); ///创建一个数据库链接,如果带上后面参数 $db_name 创建一个到数据库$db_name的链接,如果后面不带参数,创建一个到server的链接,在后面可以使用 $con -> select_db($db_name);来选择数据表
Copy after login

Create database

try{ $con -> query($create_db); }catch (exception$e){ } $con -> select_db("nwpu"); ///使用try 可以避免重复创建数据库报错,
Copy after login

Create data table

$table = "createtable name(". "firstvarchar(20) PRIMARYKEY,". "sec VARCHAR(20)". ")"; $con -> query($table); ///使用query执行sql语句
Copy after login

Close database

$con -> close();
Copy after login
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the PHP database operation mysqli, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
Why is "this" defined as undefined in Vue 3 function Please look at the following simple component example in Vue3: