新聞中心
PHP如何查詢數(shù)據(jù)并顯示結(jié)果。
這個(gè)簡(jiǎn)單啊!
為連云港等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及連云港網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都網(wǎng)站建設(shè)、做網(wǎng)站、連云港網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎ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);
?
頁面美化自己去搞!只能幫你這么多了
PHP連接oracle數(shù)據(jù)庫后查詢多個(gè)表怎么輸出到對(duì)應(yīng)的表格內(nèi)?
用聯(lián)合查詢就可以實(shí)現(xiàn)
一般包括左外連接,右外連接和內(nèi)連接
可以用on設(shè)置每?jī)蓚€(gè)表之間的關(guān)聯(lián)關(guān)系,查詢后遍歷輸出到頁面就可以了
php查詢數(shù)據(jù)庫并在網(wǎng)頁上輸出結(jié)果
$sql = 'SELECT COUNT( * ) FROM DAY WHERE id_u =1' ;
$resault = $db-getAll($sql);
//
function getAll($sql)
{
$res = $this-query($sql);
if ($res !== false)
{
$arr = array();
while ($row = mysql_fetch_assoc($res))
{
$arr[] = $row;
}
return $arr;
}
else
{
return false;
}
}
//
function query($sql, $type = '')
{
if ($this-link_id === NULL)
{
$this-connect($this-settings['dbhost'], $this-settings['dbuser'], $this-settings['dbpw'], $this-settings['dbname'], $this-settings['charset'], $this-settings['pconnect']);
$this-settings = array();
}
if ($this-queryCount++ = 99)
{
$this-queryLog[] = $sql;
}
if ($this-queryTime == '')
{
if (PHP_VERSION = '5.0.0')
{
$this-queryTime = microtime(true);
}
else
{
$this-queryTime = microtime();
}
}
/* 當(dāng)當(dāng)前的時(shí)間大于類初始化時(shí)間的時(shí)候,自動(dòng)執(zhí)行 ping 這個(gè)自動(dòng)重新連接操作 */
if (PHP_VERSION = '4.3' time() $this-starttime + 1)
{
mysql_ping($this-link_id);
}
if (!($query = mysql_query($sql, $this-link_id)) $type != 'SILENT')
{
$this-error_message[]['message'] = 'MySQL Query Error';
$this-error_message[]['sql'] = $sql;
$this-error_message[]['error'] = mysql_error($this-link_id);
$this-error_message[]['errno'] = mysql_errno($this-link_id);
$this-ErrorMsg();
return false;
}
if (defined('DEBUG_MODE') (DEBUG_MODE 8) == 8)
{
$logfilename = $this-root_path . DATA_DIR . '/mysql_query_' . $this-dbhash . '_' . date('Y_m_d') . '.log';
$str = $sql . "\n\n";
if (PHP_VERSION = '5.0')
{
file_put_contents($logfilename, $str, FILE_APPEND);
}
else
{
$fp = @fopen($logfilename, 'ab+');
if ($fp)
{
fwrite($fp, $str);
fclose($fp);
}
}
}
return $query;
}
網(wǎng)頁名稱:php數(shù)據(jù)庫查詢并輸出 php查詢數(shù)據(jù)庫并輸出實(shí)例
網(wǎng)頁地址:http://www.ef60e0e.cn/article/hghcoi.html