选择指定的MySQL数据库
生活随笔
收集整理的這篇文章主要介紹了
选择指定的MySQL数据库
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
<?php/*********************************** 功能:選擇指定的MySQL數(shù)據(jù)庫(kù)*********************************/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>選擇數(shù)據(jù)庫(kù)</title>
</head>
<body background="image/bg.JPG">
<table align="center"><tr><td>
<img src="image/banner.jpg">
</td></tr><tr><td background="image/head.JPG" align="center">
<form action="" method="post"><select name="select"><option value="1" selected="selected">請(qǐng)選擇數(shù)據(jù)庫(kù)</option><!--連接數(shù)據(jù)庫(kù)-->
<?php$conn = mysql_connect("localhost","root","");$rs = mysql_query("show databases");//查詢(xún)操作//將數(shù)據(jù)庫(kù)名稱(chēng)以下拉列表的方式顯示while($rst = mysql_fetch_array($rs)){$i = 0;echo "<option value = ".$rst[$i].">".$rst[$i]."</option>";$i ++;}
?></select><input type="submit" name="sub" value="確定" />
</form>
</td></tr><tr><td background="image/head.JPG"><?phpif(!empty($_POST["sub"])){if($_POST["select"] == "1"){echo "<script>alert('請(qǐng)選擇數(shù)據(jù)庫(kù)');</script>";}else{if(mysql_select_db($_POST["select"],$conn)){echo "<script>alert('已經(jīng)連接到指定的數(shù)據(jù)庫(kù)');</script>";mysql_close();}else{echo "<script>alert('出錯(cuò)了');</script>";}}}?>
</td></tr></table></body>
</html>
?
轉(zhuǎn)載于:https://www.cnblogs.com/banshaohuan/p/4575012.html
總結(jié)
以上是生活随笔為你收集整理的选择指定的MySQL数据库的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 基址重定位
- 下一篇: 数据库主键设计之思考(转)