php 查询access数据库,修改代码,
html+php,html页面传递数据给php页面作为条件参数查询,数据库的字段username,password我需要查询结果显示在html页面上,如何实现?$rs->...
html+php ,html页面传递数据给php页面作为条件参数查询,
数据库的字段 username, password
我需要查询结果显示在html页面上,如何实现?
$rs->Open("select * from szd_t where username="$_POST["name"],$conn,1,1); 这一句是否有问题? 其他代码至少语法没有错误,
完整代码如下:
access.html
<html>
<title>html</title>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body><form name="form" action="accessdb2.php" method="post">
Name: <input type="text" name="name" />
<input type="submit" />
</form></body>
</html>
accessdb2.php
<?php
$conn = new com("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("db.mdb");
$conn->Open($connstr);
$rs = new com("ADODB.RecordSet");
$rs->Open("select * from szd_t where username="$_POST["name"],$conn,1,1);
while(! $rs->eof)
{
$f = $rs->Fields(1);
$f2 = $rs->Fields(0);
echo $f2->value;
echo $f->value;
$rs->MoveNext();
}
//echo "<script>alert('success!');</script>";
?>
最后自己解决了
accessdb2.php
<?php
$username=$_POST[name];
//echo $username;
$conn = new com("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("db.mdb");
$conn->Open($connstr);
$rs = new com("ADODB.RecordSet");
$rs->Open("select * from szd_t where username='$username'",$conn,1,1);
while(! $rs->eof)
{
$f = $rs->Fields(1);
$f2 = $rs->Fields(0);
echo $f2->value;
echo $f->value;
$rs->MoveNext();
}
$rs->Close();
$conn->Close();
//echo "<script>alert('success!');</script>";
?> 展开
数据库的字段 username, password
我需要查询结果显示在html页面上,如何实现?
$rs->Open("select * from szd_t where username="$_POST["name"],$conn,1,1); 这一句是否有问题? 其他代码至少语法没有错误,
完整代码如下:
access.html
<html>
<title>html</title>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body><form name="form" action="accessdb2.php" method="post">
Name: <input type="text" name="name" />
<input type="submit" />
</form></body>
</html>
accessdb2.php
<?php
$conn = new com("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("db.mdb");
$conn->Open($connstr);
$rs = new com("ADODB.RecordSet");
$rs->Open("select * from szd_t where username="$_POST["name"],$conn,1,1);
while(! $rs->eof)
{
$f = $rs->Fields(1);
$f2 = $rs->Fields(0);
echo $f2->value;
echo $f->value;
$rs->MoveNext();
}
//echo "<script>alert('success!');</script>";
?>
最后自己解决了
accessdb2.php
<?php
$username=$_POST[name];
//echo $username;
$conn = new com("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("db.mdb");
$conn->Open($connstr);
$rs = new com("ADODB.RecordSet");
$rs->Open("select * from szd_t where username='$username'",$conn,1,1);
while(! $rs->eof)
{
$f = $rs->Fields(1);
$f2 = $rs->Fields(0);
echo $f2->value;
echo $f->value;
$rs->MoveNext();
}
$rs->Close();
$conn->Close();
//echo "<script>alert('success!');</script>";
?> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询