獲取ppq數(shù)據(jù)庫的所有表名的代碼:

創(chuàng)新互聯(lián)主營(yíng)彭水苗族土家族網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,成都APP應(yīng)用開發(fā),彭水苗族土家族h5成都微信小程序搭建,彭水苗族土家族網(wǎng)站營(yíng)銷推廣歡迎彭水苗族土家族等地區(qū)企業(yè)咨詢
?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()
接受一個(gè)數(shù)據(jù)庫名并返回和
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。
初學(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"請(qǐng)輸入用戶名稱
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;'對(duì)不起,您查找的用戶信息不存在!/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
如果想全部顯示 就需要循環(huán)顯示
你的錯(cuò)誤在于 $db = mysql_fetch_row($sdb)
你把這個(gè)改成 while($db = mysql_fetch_row($sdb)){rows[] =$db;}
$db = mysql_fetch_row($sdb)
因?yàn)橹粫?huì)取一個(gè)
這個(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ù)庫用戶名","數(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);
?
頁面美化自己去搞!只能幫你這么多了
我的思路是:
數(shù)據(jù)庫中新建一個(gè)表
is_showUpdate
字段:id、is_update
記錄 :id=1;is_update = false;
當(dāng)你的程序要修改顯示信息的時(shí)候(也就是展示數(shù)據(jù)),信息修改完畢將is_showUpdate表的記錄標(biāo)記為true
update is_showUpdate set is_update ='true' where id = 1;
展示頁面通過js定時(shí)器通過ajax每五秒調(diào)取下你的接口,接口只是查詢is_showUpdate 表的id為1的記錄 is_update 是否為true;如果該字段為true,則此接口將id=1的記錄的is_update修改為false,然后給前臺(tái)頁面反水?dāng)?shù)據(jù),刷新頁面;
PHP代碼如下:
/*
Author:默默
Date :2006-12-03
*/
$page=isset($_GET['page'])?intval($_GET['page']):1; //這句就是獲取page=18中的page的值,假如不存在page,那么頁數(shù)就是1。
$num=10; //每頁顯示10條數(shù)據(jù)
$db=mysql_connect("host","name","pass"); //創(chuàng)建數(shù)據(jù)庫連接
$select=mysql_select_db("db",$db); //選擇要操作的數(shù)據(jù)庫
/*
首先咱們要獲取數(shù)據(jù)庫中到底有多少數(shù)據(jù),才能判斷具體要分多少頁,具體的公式就是
總數(shù)據(jù)數(shù)除以每頁顯示的條數(shù),有余進(jìn)一。
也就是說10/3=3.3333=4 有余數(shù)就要進(jìn)一。
*/
$total=mysql_num_rows(mysql_query("select id from table")); //查詢數(shù)據(jù)的總數(shù),id是數(shù)據(jù)庫中的一個(gè)自動(dòng)賦值的字段
$pagenum=ceil($total/$num); //獲得總頁數(shù)
//假如傳入的頁數(shù)參數(shù)大于總頁數(shù),則顯示錯(cuò)誤信息
If($page$pagenum || $page == 0){
Echo "Error : Can Not Found The page .";
Exit;
}
$offset=($page-1)*$num; //獲取limit的第一個(gè)參數(shù)的值,假如第一頁則為(1-1)*10=0,第二頁為(2-1)*10=10。
$info=mysql_query("select name from table limit $offset,$num"); //獲取相應(yīng)頁數(shù)所需要顯示的數(shù)據(jù),name是數(shù)據(jù)里的一個(gè)字段
While($it=mysql_fetch_array($info)){
Echo $it['name']."
";
} //顯示數(shù)據(jù)
For($i=1;$i=$pagenum;$i++){
$show=($i!=$page)?"$i":"$i";
Echo $show." ";
}
/*顯示分頁信息,假如是當(dāng)頁則顯示粗體的數(shù)字,其余的頁數(shù)則為超連接,假如當(dāng)前為第三頁則顯示如下
1 2 3 4 5 6
*/
?
當(dāng)前標(biāo)題:php自動(dòng)顯示數(shù)據(jù)庫,php輸出顯示數(shù)據(jù)庫內(nèi)容
文章分享:http://chinadenli.net/article49/dsgsjeh.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供、網(wǎng)站制作、網(wǎng)站排名、微信公眾號(hào)、外貿(mào)建站、ChatGPT
聲明:本網(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)