Home  >  Article  >  Backend Development  >  php mysql connection database selection display all tables_PHP tutorial

php mysql connection database selection display all tables_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:05:241423browse

Here we mainly talk about three practical functions about database connection and database selection in PHP and displaying all tables of the current database. Friends in need can take a look.

Here we mainly talk about the three practical functions of database tutorial connection and database selection in the PHP tutorial, as well as displaying all tables of the current database. Friends in need can take a look.

$phps tutorial ql_user = "root";
$phpsql_password = "root";
$phpsql_loc = "";
$phpsql_db = "";


function phpsql_connect($location, $username, $password){
global $phpsql_loc, $phpsql_user, $phpsql_password;
if($phpsql_user != $username || $phpsql_password != $password)
phpsql_error("cannot access to phpsql!(wrong username/wrong password)");
define(phpsql_loc, $location);
$phpsql_loc = $location;
}
function phpsql_select_db($db){
global $phpsql_db;
define(phpsql_db, $db);
$phpsql_db = $db;
}
function phpsql_list_table(){
global $phpsql_loc, $phpsql_db;
$i = 0;
if(!($handle = @opendir($phpsql_loc."/".$phpsql_db)))
return 0;
while(($file = readdir($handle)) !== false){
if($file != "." && $file != "..")
{
$table[$i ++] = $file;
}
}
return $table;
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630778.htmlTechArticleHere we mainly talk about three practical functions about database connection and database selection in php and displaying all tables of the current database. Friends in need can take a look. Here we mainly talk about...
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