新聞中心
php如何查詢數(shù)據(jù)庫表中的數(shù)據(jù)并顯示
這個簡單?。?/p>
創(chuàng)新互聯(lián)建站主要從事成都網(wǎng)站設(shè)計、成都做網(wǎng)站、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)桓臺,10多年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):13518219792
首頁做個前臺輸入姓名和會員卡信息的頁面,我做個簡單的頁面給你看
!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會員查詢系統(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
然后我給你一個test.php的文件代碼:
?php
$name????=????trim($_POST['name']);
$vipid????=????trim($_POST['vipid']);
$con?=?mysql_connect("127.0.0.1","數(shù)據(jù)庫用戶名","數(shù)據(jù)庫密碼");
if?(!$con)
{
die('Could?not?connect:?'?.?mysql_error());
}
$a????=????mysql_select_db("數(shù)據(jù)庫名字",?$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顯示所有數(shù)據(jù)庫
如果想全部顯示 就需要循環(huán)顯示
你的錯誤在于 $db = mysql_fetch_row($sdb)
你把這個改成 while($db = mysql_fetch_row($sdb)){rows[] =$db;}
$db = mysql_fetch_row($sdb)
因為只會取一個
如何用php獲取數(shù)據(jù)庫信息并顯示
獲取ppq數(shù)據(jù)庫的所有表名的代碼:
?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ù)很相似的一個結(jié)果指針。用
mysql_fetch_array()或者用mysql_fetch_row()來獲得一個數(shù)組,數(shù)組的第0列就是數(shù)組名,當(dāng)獲取不到時
mysql_fetch_array()或者用mysql_fetch_row()返回
FALSE。
php用表單形式顯示數(shù)據(jù)庫信息
初學(xué)者寫的,你可以試試
form?name="myform"?method="post"?action="mysql.php"
table?border="1"
tr
td?width="605"?height="51"?bgcolor="#CC99FF"?colspan="2"
div?align="center"請輸入用戶名稱
input?name="txt_user"?type="text"?id="txt_user"?size="25"nbsp;
input?type="submit"?name="Submit"?value="查詢"
/div
/td
/tr
tr
td?align='center'用戶名稱/td
td?align='center'年齡/td
/tr
?php
//?mysql_connect(服務(wù)器,用戶名,密碼)
$link?=?mysql_connect("localhost","root","root");
//?mysql_select_db(數(shù)據(jù)庫,$link)
$db_selected?=?mysql_select_db("php_test",$link);
//?編碼格式(貌似很重要)
mysql_query("set?names?'utf8'");
?
?php
$sql?=?mysql_query("select?name_,age_?from?t_user");
$info?=?mysql_fetch_array($sql);
if($_POST[Submit]=="查詢"){
$txt_user?=?$_POST[txt_user];
$sql?=?mysql_query("select?*?from?t_user?where?name_?like?'%".trim($txt_user)."%'");
$info?=?mysql_fetch_array($sql);
}
?
?php
if($info==false){
echo?'trtd?width="605"?height="51"?bgcolor="#CC99FF"?colspan="2"';
echo?"div?align='center'?style='color:#FF0000;font-size:12px;'對不起,您查找的用戶信息不存在!/div";
echo?'/td/tr';
}elseif($info){
echo?'elseif';
}
?
?php
do{
?
tr?align="center"?bgcolor="#FFFFFF"
td?height="20"align="center"??php?echo?$info['NAME_']?/td
td??php?echo?$info['AGE_']?/td
/tr
?php
}while($info?=?mysql_fetch_array($sql));
mysql_free_result($sql);
mysql_close($link);
?
/table
/form
php中怎么在表格中顯示數(shù)據(jù)庫數(shù)據(jù)?
數(shù)據(jù)上傳到php空間 。。數(shù)據(jù)代碼填對應(yīng)的數(shù)據(jù)內(nèi)容就可以了。。比如images=“xxxx.jif”把文件gif上傳到空間就好了。。路勁要指示真確。。。
分享名稱:php展示數(shù)據(jù)庫數(shù)據(jù) php實現(xiàn)數(shù)據(jù)庫查詢
網(wǎng)站路徑:http://www.dlmjj.cn/article/docjpji.html