十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團隊
量身定制 + 運營維護+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
編寫調(diào)試代碼,回答有點晚了,以下是一個比較完整的示例:
專注于為中小企業(yè)提供成都網(wǎng)站制作、做網(wǎng)站服務(wù),電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)渭源免費做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了上千余家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實現(xiàn)規(guī)模擴充和轉(zhuǎn)變。
下面輸出一個表格,兩個輸入框,輸入用戶號和密碼:
form id="form1" name="form1" method="post" action="chaxun.php"
table width="344" height="136" border="0" align="center" cellpadding="2" cellspacing="2"
td width="100" height="35" align="right"用戶號:/td
td width="275"input type="text" name="online_number" id="online_number" width="150" //td
/tr
tr
td align="right"密碼:/td
td height="35"input type="password" name="online_pass" id="online_pass" width="150" //td
/tr
tr
td height="45" colspan="2" align="center"input type="submit" value="注冊" / /td
/tr
/table
/form
?php
//下面編寫處理代碼,有說明
header('Content-type:text/html;charset=utf-8');//設(shè)置編碼格式為utf8
if(isset($_POST['online_number']) isset($_POST['online_pass']))
{
$db = new mysqli('localhost','test','test','db_online');//建立數(shù)據(jù)庫連接,用戶名、密碼、數(shù)據(jù)庫根據(jù)實際修改
$pass = $_POST['online_pass'];
$num = $_POST['online_number'];
$rows = $db-query("SELECT * FROM tb_user WHERE online_number = $num AND online_pass ='$pass'");
$r_num = $rows-num_rows;
if($r_num0)
{
echo 'table border="1"tr';
$row = $rows-fetch_row();
for($i=0;$icount($row);$i++)
{
echo 'td'.$row[$i].'/td';
}
echo '/tr';
} else
echo 'scriptalert("用戶號或密碼錯誤");/script';
}
?
將以上代碼保存為chaxun.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。
這個簡單??!
首頁做個前臺輸入姓名和會員卡信息的頁面,我做個簡單的頁面給你看
!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);
?
頁面美化自己去搞!只能幫你這么多了
你所涉及的問題有兩方面。
1、php列表程序;把文章標(biāo)題、作者、日期、點擊率等列表顯示。
2、php分頁程序;對當(dāng)所有的列表項進行分面,并按照分頁進行顯示。
因為列表程序可以說是項目中比較重要的程序,就像電腦主板一樣,上面承載有很多的鏈接,相對有點復(fù)雜。簡單一點跟你說,又怕你弄不清楚,說詳細(xì)一點,你可能又更糊涂了。下面把思路跟你說一下吧:
(1)從數(shù)據(jù)庫中循環(huán)讀出符合要求的記錄,不斷賦值給數(shù)組,如$title[$i];
在這期間,要獲取記錄總數(shù)、總頁數(shù)、當(dāng)前頁數(shù)等內(nèi)容;
(2)做靜態(tài)頁面,循環(huán)做表格(行),從數(shù)組中不斷取值;
(3)顯示分頁的鏈接和跳轉(zhuǎn)行;
程序并不是很難,只是比較繁瑣。如果你急需現(xiàn)成的,就把數(shù)據(jù)庫相關(guān)信息發(fā)到我郵箱,幫你定制一個,你自己再改。
php是采用二進制形式存儲圖片及讀取顯示的,首先通過代碼創(chuàng)建數(shù)據(jù)表,然后上傳圖片服務(wù)器再通過瀏覽器顯示,具體編程代碼舉例:
1、首先需要創(chuàng)建數(shù)據(jù)表,具體代碼如下圖所示。
2、然后寫上傳圖片到服務(wù)器的頁面 upimage.html用來將圖片上傳數(shù)據(jù)庫,如下圖所示代碼。
3、處理圖片上傳的php upimage.php文件,如下圖所示圖片已儲存到數(shù)據(jù)庫。
4、顯示圖片的php getimage.php文件,為了看一下效果提前把ID寫入代碼。
5、預(yù)覽網(wǎng)站從數(shù)據(jù)庫中提取了圖片,并顯示到頁面上。