各位大哥帮忙啊,连接的是postgresql数据库,比如有表名为:table ,里面有字段:ID,card,name
现在从表单中输入card的值,然后在table中查找card的值并输出该行,
各位大哥该怎么弄??

解决方案 »

  1.   

    1.php<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    </head>
    <body>
    <form action="2.php" method="post">
    <input type="text" name="card" id="card"/>
    <input type="submit" name="submit" > 
    </form>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    </head>
    <body>
    2.php<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    </head>
    <body>
    <div align="center">
    <table border="2">
      <tr>
        <td>ID</td>
        <td>card</td>
        <td>name</td>
      </tr>
    <?php 
    $card=$_POST["card"];

    $host="localhost";//数据库地址
    $user="root";//连接用户名
    $pwd="";//密码
    $base="";//数据库名称
    @$con=mysql_connect($host,$user,$pwd) or die("连接失败");
    @mysql_select_db($base) or die("数据库名称出错"); $sql="select * from table where card='".$card."'";
    $i=0; 
            while($row = mysql_fetch_array($result)){ ?>
                <tr> <?php while($i<3){?>
    <td><?php echo $row[$i];?></td><?php $i++;
    }
    }?>
    </tr>
    </table>
    </div>
    </body>
    </html>
      

  2.   

    1.php 最后一段复制错了<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    </head>
    <body>
    <form action="2.php" method="post">
    <input type="text" name="card" id="card"/>
    <input type="submit" name="submit" > 
    </form>
    </body>
    </html>