php如何查询数据库表中的数据并显示

界面显示A、B两个文本输入框,输入数字后点击按钮查询,A、B同时等于数据库中A、B列的值,结果显示数据库中的对应C字段。怎么实现,第一次接触PHP,求大神指导

这个简单啊!
首页做个前台输入姓名和会员卡信息的页面,我做个简单的页面给你看
<!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);
?>


页面美化自己去搞!只能帮你这么多了

追问

你这个代码我从百度找到过,而且也试了,报错。就后面查询那一块,你帮我重新写一个,谢谢

温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网