兩種情況。

創(chuàng)新互聯(lián)建站自成立以來,一直致力于為企業(yè)提供從網(wǎng)站策劃、網(wǎng)站設(shè)計(jì)、網(wǎng)站制作、做網(wǎng)站、電子商務(wù)、網(wǎng)站推廣、網(wǎng)站優(yōu)化到為企業(yè)提供個(gè)性化軟件開發(fā)等基于互聯(lián)網(wǎng)的全面整合營(yíng)銷服務(wù)。公司擁有豐富的網(wǎng)站建設(shè)和互聯(lián)網(wǎng)應(yīng)用系統(tǒng)開發(fā)管理經(jīng)驗(yàn)、成熟的應(yīng)用系統(tǒng)解決方案、優(yōu)秀的網(wǎng)站開發(fā)工程師團(tuán)隊(duì)及專業(yè)的網(wǎng)站設(shè)計(jì)師團(tuán)隊(duì)。
1、你剛學(xué)php沒有使用框架。每一個(gè)框架的的獲取數(shù)據(jù)的方法不一樣。他們功能的特點(diǎn)是都會(huì)配置數(shù)據(jù)連接,所以你只要按照他們的配置,進(jìn)行配置就可以,一般要用戶名密碼,數(shù)據(jù)庫(kù)名。例如speed的位:
$spConfig = array(
'db' = array(
'host' = 'xxxx',
'login' = 'xxx',
'password' = 'xx',
'database' = 'xxx')
)
然后在模型(sql語句,指出表名,字段)中寫好表,以獲取。具體的學(xué)框架。寫出來太多了。
2、直接連接使用。我寫了點(diǎn)代碼如下:
$host ='';/主機(jī)
$login = '';//用戶
$password = '';//密碼
$database = '';//數(shù)據(jù)庫(kù)
$con = mysql_connect($host,$login,$password);
if(!$con)
{
die('could no neect'.mysql_error());
}
mysql_select_db($database,$con);
$result = mysql_query("select test from Test)//你的表
while($row = mysql_fetch_array($result))
{
echo $row[test];//字段名
}
mysql_close($con);
不懂再問!
$con=mysql_connect('localhost','root','');//數(shù)據(jù)庫(kù)信息
mysql_select_db('shop');//數(shù)據(jù)庫(kù)名
mysql_query("set names utf8");//設(shè)置字符集編碼
$sql="select goods_name,goods_number,shop_price from goods";//查詢語句
$res=mysql_query($sql);//執(zhí)行查詢
while($row=mysql_fetch_assoc($res)){
$rows[]=$row;//接受結(jié)果集
}
//遍歷數(shù)組
foreach($rows as $key=$v){
echo $v['goods_name']."---".$v['goods_number']."---".$v['shop_price']."";
}
這個(gè)簡(jiǎn)單啊!
首頁做個(gè)前臺(tái)輸入姓名和會(huì)員卡信息的頁面,我做個(gè)簡(jiǎn)單的頁面給你看
!DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?""
html?xmlns=""
head
meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/
title會(huì)員查詢系統(tǒng)/title
/head
body
form?id="form1"?name="form1"?method="post"?action="test.php"
p
label?for="name"/label
input?type="text"?name="name"?id="name"?/
/p
p
label?for="vipid"/label
input?type="text"?name="vipid"?id="vipid"?/
/p
p
input?type="submit"?name="button"?id="button"?value="查詢"?/
/p
/form
/body
/html
然后我給你一個(gè)test.php的文件代碼:
?php
$name????=????trim($_POST['name']);
$vipid????=????trim($_POST['vipid']);
$con?=?mysql_connect("127.0.0.1","數(shù)據(jù)庫(kù)用戶名","數(shù)據(jù)庫(kù)密碼");
if?(!$con)
{
die('Could?not?connect:?'?.?mysql_error());
}
$a????=????mysql_select_db("數(shù)據(jù)庫(kù)名字",?$con);
$sql????=????"select?*?from?kh_customer?where?name?=?'$name'?and?vipid?=?'$vipid'";
$result?=?mysql_query($sql);
while($row?=?mysql_fetch_array($result))
{
echo?$row['name']?.?"?"?.?$row['data'];
echo?"br?/";
}
mysql_close($con);
?
頁面美化自己去搞!只能幫你這么多了
php是采用二進(jìn)制形式存儲(chǔ)圖片及讀取顯示的,首先通過代碼創(chuàng)建數(shù)據(jù)表,然后上傳圖片服務(wù)器再通過瀏覽器顯示,具體編程代碼舉例:
1、首先需要?jiǎng)?chuàng)建數(shù)據(jù)表,具體代碼如下圖所示。
2、然后寫上傳圖片到服務(wù)器的頁面 upimage.html用來將圖片上傳數(shù)據(jù)庫(kù),如下圖所示代碼。
3、處理圖片上傳的php upimage.php文件,如下圖所示圖片已儲(chǔ)存到數(shù)據(jù)庫(kù)。
4、顯示圖片的php getimage.php文件,為了看一下效果提前把ID寫入代碼。
5、預(yù)覽網(wǎng)站從數(shù)據(jù)庫(kù)中提取了圖片,并顯示到頁面上。
獲取ppq數(shù)據(jù)庫(kù)的所有表名的代碼:
?php
$server='localhost';
$user='root';
$pass='12345';
$dbname='ppq';
$conn=mysql_connect($server,$user,$pass);
if(!$conn)
die("數(shù)據(jù)庫(kù)系統(tǒng)連接失敗!");
$result=mysql_list_tables($dbname);
if(!$result)
die("數(shù)據(jù)庫(kù)連接失敗!");
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ù)庫(kù)中的表
說明
resource
mysql_list_tables
(
string
database
[,
resource
link_identifier])
mysql_list_tables()
接受一個(gè)數(shù)據(jù)庫(kù)名并返回和
mysql_query()
函數(shù)很相似的一個(gè)結(jié)果指針。用
mysql_fetch_array()或者用mysql_fetch_row()來獲得一個(gè)數(shù)組,數(shù)組的第0列就是數(shù)組名,當(dāng)獲取不到時(shí)
mysql_fetch_array()或者用mysql_fetch_row()返回
FALSE。
首先是一個(gè)input class=dh
查詢按鈕 class=cx
圖片框 class=tp
點(diǎn)擊查詢按鈕時(shí)
script
$(".cx").click(function(){
var dh= $('.dh').val();//獲取輸入的電話
$.post('date.php',{tel:dh},function(result){
//將獲取到的電話號(hào)碼提交給date.php文件,date.php文件 通過查詢tel='$_POST[tel]' 得到圖片地址$src,echo $src;result即使那個(gè)返回的$src
$('.tp').find('img').attr('src', result);//將圖片框內(nèi)容改掉
});
});
/script
需要jquery支持 就是頁面要載入
script type="text/javascript" src="js/jquery.js"/script
本文標(biāo)題:php讀入數(shù)據(jù)并顯示 php讀取數(shù)據(jù)表內(nèi)容
分享鏈接:http://chinadenli.net/article28/higjjp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、靜態(tài)網(wǎng)站、網(wǎng)站收錄、全網(wǎng)營(yíng)銷推廣、營(yíng)銷型網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)