重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
header("Content-type:text/html;charset=utf-8");
创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都做网站、成都网站建设、成都外贸网站建设、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的清徐网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
mysql_connect('主机名','账号','密码');
mysql_select_db('数据库名');
mysql_query('set names utf8');
$sql="SELECT username,regdate FROM 表名 where username='".$_GET['USERNAME']."'";
$res=mysql_query($sql);
if($row = mysql_fetch_row($res)){
$json = array(
'state'=true,
'username'=$row[0],
'regdate'=$row[1],
'rand_num'=date('Y/m/d H:i:s')
);
}else{
$json = array(
'state'=false,
'rand_num'=date('Y/m/d H:i:s')
);
}
echo json_encode($json);
exit();
明白的人应该一眼就能看懂吧
面向过程:
$sql = "select t_bumen from t_xinxi where id=111"; //Sql语句
$result = mysql_fetch_assoc(mysql_query($sql)); //执行sql语句并以关联数组保存
print_r($result); //输出数组
将数据print_r 打印出来 如:
include_once("connect.php");
$q=mysql_query("select * from comments");
while($row=mysql_fetch_array($q)){
$comments[] = array("id"=$row[id],"user"=$row[user],"comment"=$row[comment],"addtime"=$row[addtime]);
}
print_r($comments);
echo json_encode($comments);
这个简单啊!
首页做个前台输入姓名和会员卡信息的页面,我做个简单的页面给你看
!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会员查询系统/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","数据库用户名","数据库密码");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$a = mysql_select_db("数据库名字", $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代码中,用SQL语句查询查询数据库里面的信息,并显示出来
$question
$sql= "select *from tableName where question='$question' ";
//tableName 是你数据库的名字
// question 是你数据库的字段名字
// $question 是你问题的答案
这个简单啊!
首页做个前台输入姓名和会员卡信息的页面,我做个简单的页面给你看
!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会员查询系统/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","数据库用户名","数据库密码");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$a = mysql_select_db("数据库名字", $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);
?
页面美化自己去搞!只能帮你这么多了