新聞中心
PHP 如何以表單形式顯示數(shù)據(jù)庫所有內(nèi)容
用while語句來循環(huán)所有的條目。這樣添加或者刪除的時候就不會出現(xiàn)你所說的問題!
創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供圖們網(wǎng)站建設、圖們做網(wǎng)站、圖們網(wǎng)站設計、圖們網(wǎng)站制作等企業(yè)網(wǎng)站建設、網(wǎng)頁設計與制作、圖們企業(yè)網(wǎng)站模板建站服務,十年圖們做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡服務。
table
trth用戶id/thth用戶名/th/tr
?$sql=SELECT .....;//這個不用我寫了吧!
$re=mysql_query($sql);
$row=mysql_num_rows($re);//返回取得的數(shù)據(jù)列的數(shù)目
if($row){ //判斷數(shù)據(jù)庫中是否有值
while($row2=mysql_fetch_array($re)){ //注意括號結(jié)束的位置
$usid=$row2['usid'];
$username=$row2['usname'];
?
trtd?echo $usid;?/tdtd?echo $username;?/td/tr
?} //while循環(huán)結(jié)束的括號
} //if結(jié)束的括號
?
/table
建議你還是先找個完整的項目,照著自己打打代碼!
我掙點分真不容易!
php顯示數(shù)據(jù)庫某個表的所有內(nèi)容怎么寫
while($row?=?mysql_fetch_row($rows)){
$rows[]?=?$row;
}
//遍歷$rows數(shù)組(二維數(shù)組),可以一次性輸出表格
PHP如何利用循環(huán)輸出數(shù)據(jù)庫表中所有記錄
?php
mysql_select_db("infosystem",
$link);
//選擇數(shù)據(jù)庫
$q
=
"SELECT
*
FROM
info";
//SQL查詢語句
mysql_query("SET
NAMES
GB2312");
$rs
=
mysql_query($q,
$link);
//獲取數(shù)據(jù)集
if(!$rs){die("Valid
result!");}
echo
"table";
echo
"trtd部門名稱/tdtd員工姓名/tdtdPC名稱/td/tr";
while($row
=
mysql_fetch_row($rs))
echo
"trtd$row[1]/tdtd$row[2]/tdtd$row[3]/td/tr";
//顯示數(shù)據(jù)
echo
"/table";
mysql_free_result($rs);
//關閉數(shù)據(jù)集
php顯示mysql所有數(shù)據(jù)庫表中信息
啊,明白了,我圖方便就簡寫了,沒按照規(guī)范,你就自己規(guī)范寫吧
$cnt = select count(`id`) as `num` from `tablename` //這是取得數(shù)據(jù)庫內(nèi)的數(shù)據(jù)數(shù)量
$datas = select `id`, `picname`,`picpath` from `tablename`
兩種啊,第一種
foreach ( $datas as $data )
{
$del = "delete from `tablename` where `id`={$data['id']}";
@unlike( "{$data['picpath']}" );//這里取決于你存的是相對還是絕對路徑
echo("名稱:$data['picname']");//顯示文件名稱
echo("
如何用php取出數(shù)據(jù)庫表中一列所有數(shù)據(jù)
用該列的字段名即可,select語句的通用形式如下:
select 你要的信息
from 數(shù)據(jù)表(一個或多個)
where 滿足的條件
所以你的sql語句為:
select 要取得列名 from 表名 where 1
例子
SELECT id FROM `article` where 1
如何用php取出數(shù)據(jù)庫表中一列所有數(shù)據(jù)?
很簡單,用循環(huán),你那樣用只能有一條記錄,建議多看看php手冊,對自己有好處
while ($result= mysql_fetch_array($result, MYSQL_NUM)) {
print_r($result);
}
當前文章:php表格數(shù)據(jù)庫所有內(nèi)容 php表單顯示數(shù)據(jù)庫內(nèi)容
網(wǎng)站URL:http://fisionsoft.com.cn/article/hhcspe.html