欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

php調用數(shù)據(jù)庫某個值 php引用數(shù)據(jù)庫

PHP如何取到mysql數(shù)據(jù)庫中某個字段的值

查詢成功了,但是你沒有把查詢的值賦給變量,所以你肯定得不到值,

成都創(chuàng)新互聯(lián)長期為成百上千客戶提供的網(wǎng)站建設服務,團隊從業(yè)經(jīng)驗10年,關注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務;打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為米東企業(yè)提供專業(yè)的成都網(wǎng)站建設、成都網(wǎng)站制作米東網(wǎng)站改版等技術服務。擁有10余年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。

$sql

=

"SELECT

meta_value

FROM

wp_postmeta

WHERE

meta_key

=

'img-link'

and

post_id

=1";

$result=mysql_query($sql);

while

($row

=

mysqli_fetch_assoc($result))//用myql_fetch_assoc函數(shù)取值,可以確保多行數(shù)據(jù)時能循環(huán)輸出,mysql_fetch_array只能取得最前面的一行數(shù)據(jù)

{

echo

$row['meta_value'];//輸出你想要的字段值

}

PHP調用三種數(shù)據(jù)庫的方法(3)

Oracle(甲骨文)是世界上最為流行的關系數(shù)據(jù)庫。它是大公司推崇的工業(yè)化的強有力的引擎。我們先看看其相關的函數(shù):

(1)integer

ora_logon(string

user

,

string

password)

開始對一個Oracle數(shù)據(jù)庫服務器的連接。

(2)integer

ora_open(integer

connection)

打開給出的連接的游標。

(3)integer

ora_do(integer

connection,

string

query)

在給出的連接上執(zhí)行查詢。PHP生成一個指示器,解析查詢,并執(zhí)行之。

(4)integer

ora_parse(integer

cursor,

string

query)

解析一個查詢并準備好執(zhí)行。

(5)boolean

ora_exec(integer

cursor)

執(zhí)行一個先前由ora_parse函數(shù)解析過的查詢。

(6)boolean

ora_fetch(integer

cursor)

此函數(shù)會使得一個執(zhí)行過的查詢中的行被取到指示器中。這使得您可以調用ora_getcolumn函數(shù)。

(7)string

ora_getcolumn(integer

cursor,

integer

column)

返回當前的值。列由零開始的數(shù)字索引。

(8)boolean

ora_logoff(integer

connection)

斷開對數(shù)據(jù)庫服務器的鏈接。

以下是向ORACLE數(shù)據(jù)庫插入數(shù)據(jù)的示例程序:

html

headtitle向ORACLE數(shù)據(jù)庫中插入數(shù)據(jù)/title/head

body

form

action="?echo

$PHP_SELF;?"

method="post"

table

border="1"

cellspacing="0"

cellpadding="0"

tr

thID/th

thname/th

thDescription/th

/tr

tr

tdinput

type="text"

name="name"

maxlength="50"

size="10"/td

tdinput

type="text"

name="email"

maxlength="255"

size="30"/td

tdinput

type="text"

name="Description"

maxlength="255"

size="50"/td

/tr

tr

align="center"

td

colspan="3"input

type="submit"

value="提交" input

type="reset"

value="重寫"/td

/tr

/table

/form

?

//先設置兩個環(huán)境變量ORACLE_HOME,ORACLE_SID

putenv("ORACLE_HOME=/oracle/app/oracle/product/8.0.4");

putenv("ORACLE_SID=ora8");

//設置網(wǎng)頁顯示中文

putenv("NLS_LANG=Simplified_Chinese.zhs16cgb231280");

if($connection=ora_logon("scott","tiger"))

{

//庫表test有ID,name,Description三項

$sql

=

'insert

into

test(ID,name,Description)

values

';

$sql

.=

'(''

.

$ID

.

'',''

.

$name

.

'',''.

$Description

.

'')';

if($cursor=ora_do($connect,$sql))

{

print("insert

finished!");

}

$query

=

'select

*

from

test';

if($cursor=ora_do($connect,$query))

{

ora_fetch($cursor);

$content0=ora_getcolumn($cursor,0);

$content1=ora_getcolumn($cursor,1);

$content2=ora_getcolumn($cursor,2);

print("$content0");

print("$content1");

print("$content2");

ora_close($cursor);

}

ora_logoff($connection);

}

?

/body

/html

php調用數(shù)據(jù)庫字段

這個先連接數(shù)據(jù)庫,然后調用,代碼如下:

$dbhost?=?'localhost:3306';??//?mysql服務器主機地址

$dbuser?=?'root';????????????//?mysql用戶名

$dbpass?=?'123456';??????????//?mysql用戶名密碼

$conn?=?mysqli_connect($dbhost,?$dbuser,?$dbpass);

if(!?$conn?){

die('Could?not?connect:?'?.?mysqli_error());

}

echo?'數(shù)據(jù)庫連接成功!';mysqli_close($conn);

$sql=mysql_query("select?*??from?wx_agent_orders?where?id=1");

$row=mysql_query($conn,$sql);

while($r=mysql_fetch_array($row)){

echo?$r['sendcontent']

}

這是最基礎的php獲取mysql方法了,希望采納

文章名稱:php調用數(shù)據(jù)庫某個值 php引用數(shù)據(jù)庫
網(wǎng)頁地址:http://chinadenli.net/article26/doedpcg.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設計網(wǎng)站設計公司服務器托管全網(wǎng)營銷推廣手機網(wǎng)站建設

廣告

聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設