php顯示數(shù)據(jù)庫輸出 php表格顯示數(shù)據(jù)庫信息

php輸出數(shù)據(jù)庫信息

1. 查看具體值:

在當(dāng)雄等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站建設(shè)、做網(wǎng)站 網(wǎng)站設(shè)計制作專業(yè)公司,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站設(shè)計,營銷型網(wǎng)站,成都外貿(mào)網(wǎng)站建設(shè),當(dāng)雄網(wǎng)站建設(shè)費用合理。

echo $result[0];

2. 打印數(shù)組(使用源代碼看的情況下會很清楚)

print_r($row);

3. 使用php自帶的調(diào)試函數(shù)看數(shù)據(jù)結(jié)構(gòu):

var_dump($row);

PHP實現(xiàn)上傳圖片到數(shù)據(jù)庫并顯示輸出的方法

本文實例講述了PHP實現(xiàn)上傳圖片到數(shù)據(jù)庫并顯示輸出的方法。分享給大家供大家參考,具體如下:

1.

創(chuàng)建數(shù)據(jù)表

CREATE

TABLE

ccs_image

(

id

int(4)

unsigned

NOT

NULL

auto_increment,

description

varchar(250)

default

NULL,

bin_data

longblob,

filename

varchar(50)

default

NULL,

filesize

varchar(50)

default

NULL,

filetype

varchar(50)

default

NULL,

PRIMARY

KEY

(id)

)engine=myisam

DEFAULT

charset=utf8

2.

用于上傳圖片到服務(wù)器的頁面

upimage.html

!doctype

html

html

lang="en"

head

meta

charset="UTF-8"

meta

name="viewport"

content="width=device-width,

user-scalable=no,

initial-scale=1.0,

maximum-scale=1.0,

minimum-scale=1.0"

meta

http-equiv="X-UA-Compatible"

content="ie=edge"

style

type="text/css"

*{margin:

1%}

/style

titleDocument/title

/head

body

form

method="post"

action="upimage.php"

enctype="multipart/form-data"

描述:

input

type="text"

name="form_description"

size="40"

input

type="hidden"

name="MAX_FILE_SIZE"

value="1000000"

br

上傳文件到數(shù)據(jù)庫:

input

type="file"

name="form_data"

size="40"br

input

type="submit"

name="submit"

value="submit"

/form

/body

/html

3.

處理圖片上傳的php

upimage.php

?php

if

(isset($_POST['submit']))

{

$form_description

=

$_POST['form_description'];

$form_data_name

=

$_FILES['form_data']['name'];

$form_data_size

=

$_FILES['form_data']['size'];

$form_data_type

=

$_FILES['form_data']['type'];

$form_data

=

$_FILES['form_data']['tmp_name'];

$dsn

=

'mysql:dbname=test;host=localhost';

$pdo

=

new

PDO($dsn,

'root',

'root');

$data

=

addslashes(fread(fopen($form_data,

"r"),

filesize($form_data)));

//echo

"mysqlPicture=".$data;

$result

=

$pdo-query("INSERT

INTO

ccs_image

(description,bin_data,filename,filesize,filetype)

VALUES

('$form_description','$data','$form_data_name','$form_data_size','$form_data_type')");

if

($result)

{

echo

"圖片已存儲到數(shù)據(jù)庫";

}

else

{

echo

"請求失敗,請重試";

注:圖片是以二進制blob形式存進數(shù)據(jù)庫的,像這樣

4.

顯示圖片的php

getimage.php

?php

$id

=2;//

$_GET['id'];

為簡潔,直接將id寫上了,正常應(yīng)該是通過用戶填入的id獲取的

$dsn='mysql:dbname=test;host=localhost';

$pdo=new

PDO($dsn,'root','root');

$query

=

"select

bin_data,filetype

from

ccs_image

where

id=2";

$result

=

$pdo-query($query);

$result=$result-fetchAll(2);

//

var_dump($result);

$data

=

$result[0]['bin_data'];

$type

=

$result[0]['filetype'];

Header(

"Content-type:

$type");

echo

$data;

到瀏覽器查看已經(jīng)上傳的圖片,看是否可以顯示

是沒有問題的,證明圖片已經(jīng)以二進制的形式存儲到數(shù)據(jù)庫了

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php+mysql數(shù)據(jù)庫操作入門教程》、《php+mysqli數(shù)據(jù)庫程序設(shè)計技巧總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計入門教程》、《PHP數(shù)組(Array)操作技巧大全》、《php字符串(string)用法總結(jié)》及《php常見數(shù)據(jù)庫操作技巧匯總》

希望本文所述對大家PHP程序設(shè)計有所幫助。

您可能感興趣的文章:php實現(xiàn)上傳圖片保存到數(shù)據(jù)庫的方法php上傳圖片存入數(shù)據(jù)庫示例分享php上傳圖片到指定位置路徑保存到數(shù)據(jù)庫的具體實現(xiàn)php中如何將圖片儲存在數(shù)據(jù)庫里php下將圖片以二進制存入mysql數(shù)據(jù)庫中并顯示的實現(xiàn)代碼php

從數(shù)據(jù)庫提取二進制圖片的處理代碼php將圖片保存入mysql數(shù)據(jù)庫失敗的解決方法php將圖片文件轉(zhuǎn)換成二進制輸出的方法php圖片的二進制轉(zhuǎn)換實現(xiàn)方法

PHP查詢MYSQL的內(nèi)容,并輸出結(jié)果

1、用navicat新建一個數(shù)據(jù)庫database1。

2、在database1數(shù)據(jù)庫中新建一個表table2。

3、在table2中添加新的數(shù)據(jù),新建一個名稱為mysql_query的數(shù)據(jù)庫。

4、在頁面中用mysql_connect 函數(shù)與數(shù)據(jù)庫建立連接。

5、用mysql_select_db函數(shù)選擇要查詢的數(shù)據(jù)庫。

6、添加一個查詢 table2表的查詢語句“$sql=select * from table2“。

7、將查詢語句$sql添加到查詢數(shù)據(jù)庫函數(shù)mysql_query中,返回值賦值給變量query。

8、最后將mysql_query。php文件在瀏覽器中打開,查看查詢到數(shù)據(jù)庫中的內(nèi)容的結(jié)果。

分享標(biāo)題:php顯示數(shù)據(jù)庫輸出 php表格顯示數(shù)據(jù)庫信息
網(wǎng)站鏈接:http://muchs.cn/article48/dohohep.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、網(wǎng)站策劃、網(wǎng)站設(shè)計網(wǎng)站收錄、軟件開發(fā)、網(wǎng)站設(shè)計公司

廣告

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

成都網(wǎng)站建設(shè)公司