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

解决方案 »

  1.   

    用查询语句
    select * from  table    *  代表你要查询的字段,,,可以替换成card  name  等
    得到一个结果集,遍历就可以了!!
      

  2.   

    ??????????http://www.isstudy.com
      

  3.   

    select * from table where card=$_POST['card']
    试一试吧 
      

  4.   

    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>
    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>
      

  5.   

    楼上的大哥,我用的是postgresql数据库,把2.PHP改成: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=GB2312" /> 
    <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"]; $con=pg_connect("host=localhost dbname=BenShop user=postgres password=hainan") or die("连接失败"); 
    if ($con){
    echo "连接成功";
    }
    //@pg_select_db($base) or die("数据库名称出错"); $sql="select * from table1 where card='".$card."'"; 
    $i=0; 
            while($row = pg_fetch_array($result)){ ?> 
            <tr> <?php while($i <3)
            {?> 
    <td> <?php echo $row[$i];?> </td> <?php $i++; 

    }?> 
    </tr> 
    </table> 
    </div> 
    </body> 
    </html>
    ------------------------------------------------------------------------
    出错情况是:
    Warning: pg_fetch_array() expects parameter 1 to be resource, null given in D:\wwwroot\2.php on line 32
    大哥这事什么回事???