html页面传递数据给php页面,作为条件参数查询,
数据库表 szd_t ;字段   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>";
?>

解决方案 »

  1.   

    不知道如何 测试, 服务器错误  网站在检索 http://127.0.0.1/upload/accessdb2.php 时遇到错误。 该网站可能关闭进行维护或配置不正确其实我想知道   select * from szd_t where username=‘某参数’ 查询到结果显示在 html页面上
    这个 ‘某参数’ 由 access.html 传给php页面处理
    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> 
      

  2.   

    最后自己解决了
    没有接触过php 语法修改只能靠猜,蒙对了,其实就是就是少了 ''两点 代码如下: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>";
    ?>