獲取ppq數(shù)據(jù)庫的所有表名的代碼:
你所需要的網(wǎng)站建設服務,我們均能行業(yè)靠前的水平為你提供.標準是產(chǎn)品質量的保證,主要從事成都網(wǎng)站設計、網(wǎng)站建設、企業(yè)網(wǎng)站建設、成都手機網(wǎng)站制作、網(wǎng)頁設計、品牌網(wǎng)站設計、網(wǎng)頁制作、做網(wǎng)站、建網(wǎng)站。創(chuàng)新互聯(lián)建站擁有實力堅強的技術研發(fā)團隊及素養(yǎng)的視覺設計專才。
?php
$server='localhost';
$user='root';
$pass='12345';
$dbname='ppq';
$conn=mysql_connect($server,$user,$pass);
if(!$conn)
die("數(shù)據(jù)庫系統(tǒng)連接失?。?);
$result=mysql_list_tables($dbname);
if(!$result)
die("數(shù)據(jù)庫連接失??!");
while($row=mysql_fetch_row($result))
{
echo
$row[0]."
";
}
mysql_free_result($result);
?
mysql_list_tables
(PHP
3,
PHP
4
,
PHP
5)
mysql_list_tables
--
列出
MySQL
數(shù)據(jù)庫中的表
說明
resource
mysql_list_tables
(
string
database
[,
resource
link_identifier])
mysql_list_tables()
接受一個數(shù)據(jù)庫名并返回和
mysql_query()
函數(shù)很相似的一個結果指針。用
mysql_fetch_array()或者用mysql_fetch_row()來獲得一個數(shù)組,數(shù)組的第0列就是數(shù)組名,當獲取不到時
mysql_fetch_array()或者用mysql_fetch_row()返回
FALSE。
sybase_connect連上數(shù)據(jù)庫。
語法: int sybase_connect(string [servername], string [username], string [password]);
返回值: 整數(shù)函數(shù)種類: 數(shù)據(jù)庫功能 本函數(shù)用來打開與 Sybase 數(shù)據(jù)庫的連接。
參數(shù) servername 為欲連上的數(shù)據(jù)庫服務器名稱。
參數(shù) username 及 password 可省略,分別為連接使用的帳號及密碼。
使用本函數(shù)需注意早點關閉數(shù)據(jù)庫,以減少系統(tǒng)的負擔。
連接成功則返回數(shù)據(jù)庫的連接代號,失敗返回 false 值。
把來自表單的數(shù)據(jù)插入數(shù)據(jù)庫
現(xiàn)在,我們創(chuàng)建一個 HTML 表單,這個表單可把新記錄插入 "Persons" 表。
這是這個 HTML 表單:
html
body
form?action="insert.php"?method="post"
Firstname:?input?type="text"?name="firstname"?/
Lastname:?input?type="text"?name="lastname"?/
Age:?input?type="text"?name="age"?/
input?type="submit"?/
/form
/body
/html
當用戶點擊上例中 HTML 表單中的提交按鈕時,表單數(shù)據(jù)被發(fā)送到 "insert.php"。"insert.php" 文件連接數(shù)據(jù)庫,并通過 $_POST 變量從表單取回值。然后,mysql_query() 函數(shù)執(zhí)行 INSERT INTO 語句,一條新的記錄會添加到數(shù)據(jù)庫表中。
下面是 "insert.php" 頁面的代碼:
?php
$con?=?mysql_connect("localhost","peter","abc123");
if?(!$con)
{
die('Could?not?connect:?'?.?mysql_error());
}
mysql_select_db("my_db",?$con);
$sql="INSERT?INTO?Persons?(FirstName,?LastName,?Age)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";
if?(!mysql_query($sql,$con))
{
die('Error:?'?.?mysql_error());
}
echo?"1?record?added";
mysql_close($con)
?
數(shù)據(jù)庫有很多種類:mysql,oracle,mssql,db2等等。PHP操作數(shù)據(jù)庫的時候,要保證該類型數(shù)據(jù)庫的擴展已開啟。這里連接的數(shù)據(jù)庫以mysql為例:?php
//數(shù)據(jù)庫服務器地址
$host="localhost";
//連接數(shù)據(jù)庫用戶名
$uname="root";
//連接數(shù)據(jù)庫密碼
$upass="";
//連接數(shù)據(jù)庫
$conn=mysql_connect($host, $uname,$upass);
//判斷連接
if(!$conn){
die("連接數(shù)據(jù)庫失敗!").mysql_errno();
}
//連接成功,其他操作省略
?
用PHP自帶函數(shù)就可以實現(xiàn),首先要過去對方的網(wǎng)頁信息,用
file_get_contents();參數(shù)是對方的URL地址,這個函數(shù)返回是一個字符串你想要的東西就在這個字符串中了
接下來就可以針對這個字符串做處理了,說下思路,正如你這個問題想獲取到航班號起飛時間,在這個網(wǎng)頁中應該有很多相同的標簽元素,它們都有共同點,用
用正則表達式preg_match();或者是
preg_match_all();這兩個函數(shù)它們都返回一個數(shù)組,這個數(shù)組存的就是你要的航班號和起飛時間,那么相同信息的數(shù)組就會出現(xiàn)了,然后在對這個數(shù)組進行分析找到你要的某個值或全部的值
獲取信息要用到的3個函數(shù)是:
file_get_contents();
preg_match();
preg_match_all();
網(wǎng)頁題目:php網(wǎng)站采集數(shù)據(jù)庫代碼,php自動采集網(wǎng)頁內(nèi)容
網(wǎng)站鏈接:http://muchs.cn/article30/hcgeso.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設、網(wǎng)站制作、虛擬主機、面包屑導航、小程序開發(fā)、定制開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)