<!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>
<p><strong>Search center</strong></p>
<table border="1" cellspacing="0" cellpadding="0" width="100%">
  <tr>
    <td colspan="3"><table border="0" cellspacing="0" cellpadding="0" width="100%">
      <tr>
        <td width="100%"><div align="center"><br />
          <strong>Search center</strong> </div></td>
        <td><p align="left">&nbsp;</p></td>
        <td width="10"><p align="left">&nbsp;</p></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td width="10" height="206"><p align="left">&nbsp;</p></td>
    <td width="100%"><div align="center">
      <form id="form1" name="form1" method="post" action="">
        <p>
          <select name="select">
            <option value="c_cas">CAS-No</option>
            <option value="c_name">Chemical Name</option>
            <option value="c_no">Product Number</option>
            <option value="c_fenzishi">Molecular Formula</option>
          </select>  
          </p>
        <p>
          <input type="text" name="chaxun" />  
          </p>
        <p>
          <input name="Submit2" type="submit"  value="go" />
        </p>
      </form>
      </div></td>
    <td><p align="left">&nbsp;</p></td>
  </tr>
  <tr>
    <td height="206">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>代码是这样的 就是要选中下拉框的其中一项为基准,文本框为条件,按按钮查询跳转到a.php显示出这个物品的全部信息怎么写啊?????

解决方案 »

  1.   

    1 。 html 表单 的 action  值 为 a.php (路径要对)
    2 。 在 a.php 中 接受 2 个form 表单参数 ,
    3 。 以这两个参数为条件 查询数据库 
    4 。 把 查出来的结果 显示出来 就OK 了
      

  2.   


    <?php require_once('../../../../Connections/mydb.php'); ?>
    <?php
    mysql_select_db($database_mydb, $mydb);
    $query_Recordset1 = "SELECT * FROM chanpinbiao";
    $Recordset1 = mysql_query($query_Recordset1, $mydb) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?><!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>
    <form id="form1" name="form1" method="post" action="">
      <table border="0" cellspacing="1" cellpadding="0" width="95%">
        <tr>
          <td width="99%" colspan="3"><p align="center">&nbsp;<?php echo $row_Recordset1['c_name']; ?></p></td>
        </tr>
        <tr>
          <td width="99%" colspan="3"><p align="center"><strong>基本信息</strong> </p></td>
        </tr>
        <tr>
          <td width="29%"><p align="right">英文名 </p></td>
          <td width="1%"><p align="left">&nbsp;</p></td>
          <td width="67%"><p align="left">&nbsp;<?php echo $row_Recordset1['c_enname']; ?></p></td>
        </tr>
        <tr>
          <td width="29%"><p align="right">产品名称 </p></td>
          <td width="1%"><p align="left">&nbsp;</p></td>
          <td width="67%"><p align="left">&nbsp;<?php echo $row_Recordset1['c_name']; ?></p></td>
        </tr>
        <tr>
          <td width="99%" colspan="3"><p align="center">&nbsp;</p></td>
        </tr>
        <tr>
          <td width="29%"><p align="right">分子结构 </p></td>
          <td width="1%"><p align="left">&nbsp;</p></td>
          <td width="67%"><p align="left">&nbsp;<?php echo $row_Recordset1['c_jiegou']; ?></p></td>
        </tr>
        <tr>
          <td width="99%" colspan="3"><p align="center">&nbsp;</p></td>
        </tr>
        <tr>
          <td width="29%"><p align="right">分子式 </p></td>
          <td width="1%"><p align="left">&nbsp;</p></td>
          <td width="67%"><p align="left">&nbsp;<?php echo $row_Recordset1['c_fenzishi']; ?></p></td>
        </tr>
        <tr>
          <td width="29%"><p align="right">分子量 </p></td>
          <td width="1%"><p align="left">&nbsp;</p></td>
          <td width="67%"><p align="left">&nbsp;<?php echo $row_Recordset1['c_fenziliang']; ?></p></td>
        </tr>
        <tr>
          <td width="29%"><p align="right">CAS 登录号 </p></td>
          <td width="1%"><p align="left">&nbsp;</p></td>
          <td width="67%"><p align="left">&nbsp;<?php echo $row_Recordset1['c_cas']; ?></p></td>
        </tr>
        <tr>
          <td width="29%"><p align="right">Product Number</p></td>
          <td width="1%"><p align="left">&nbsp;</p></td>
          <td width="67%"><p align="left">&nbsp;<?php echo $row_Recordset1['c_no']; ?></p></td>
        </tr>
        <tr>
          <td width="29%"><p align="right">EINECS 登录号 </p></td>
          <td width="1%"><p align="left">&nbsp;</p></td>
          <td width="67%"><p align="left">&nbsp;<?php echo $row_Recordset1['c_einecs']; ?></p></td>
        </tr>
        <tr>
          <td width="29%"><p align="right">备注信息:</p></td>
          <td width="1%"><p align="left">&nbsp;</p></td>
          <td width="67%"><?php echo $row_Recordset1['c_beizhu']; ?></td>
        </tr>
        <tr>
          <td width="99%" colspan="3"><p align="center"><strong>物理化学性质</strong> </p></td>
        </tr>
        <tr>
          <td width="99%" colspan="3"><p align="center">&nbsp;</p></td>
        </tr>
        <tr>
          <td width="29%"><p align="right">熔点 </p></td>
          <td width="1%"><p align="left">&nbsp;</p></td>
          <td width="67%"><p align="left"><?php echo $row_Recordset1['c_rongdian']; ?>oC</p></td>
        </tr>
        <tr>
          <td width="29%"><p align="right">水溶性 </p></td>
          <td width="1%"><p align="left">&nbsp;</p></td>
          <td width="67%"><p align="left"><?php echo $row_Recordset1['c_rongjie']; ?> G/L (20 oC)</p></td>
        </tr>
        <tr>
          <td width="29%"><p align="right">&nbsp;</p></td>
          <td width="1%"><p align="left">&nbsp;</p></td>
          <td width="67%"><p align="left">&nbsp;</p></td>
        </tr>
        <tr>
          <td width="99%" colspan="3"><p align="center"><strong>安全数据</strong> </p></td>
        </tr>
        <tr>
          <td width="99%" colspan="3"><p align="center">&nbsp;</p></td>
        </tr>
        <tr>
          <td width="29%"><p align="right">危险品标志 </p></td>
          <td width="1%"><p align="left">&nbsp;</p></td>
          <td width="67%"><p align="left"><?php echo $row_Recordset1['c_biaozhi']; ?> T;C&nbsp;&nbsp;&nbsp; <a href="http://www.chemblink.com/codes/hazardSymbolsC.pdf" target="_blank">说明</a> </p></td>
        </tr>
        <tr>
          <td width="29%"><p align="right">危险类别码 </p></td>
          <td width="1%"><p align="left">&nbsp;</p></td>
          <td width="67%"><p align="left"><?php echo $row_Recordset1['c_weixiandaima']; ?>&nbsp;&nbsp; <a href="http://www.chemblink.com/codes/riskC.pdf" target="_blank">说明</a> </p></td>
        </tr>
        <tr>
          <td width="29%"><p align="right">安全说明 </p></td>
          <td width="1%"><p align="left">&nbsp;</p></td>
          <td width="67%"><p align="left"><?php echo $row_Recordset1['c_anquan']; ?>&nbsp;&nbsp; <a href="http://www.chemblink.com/codes/safetyC.pdf" target="_blank">说明</a> </p></td>
        </tr>
        <tr>
          <td width="29%"><p align="right">危险品运输编号 </p></td>
          <td width="1%"><p align="left">&nbsp;</p></td>
          <td width="67%"><p align="left">&nbsp;<?php echo $row_Recordset1['c_yunshino']; ?></p></td>
        </tr>
        <tr>
          <td width="29%"><p align="right">MSDS</p></td>
          <td width="1%"><p align="left">&nbsp;</p></td>
          <td width="67%"><p align="left"><a href="http://www.chemblink.com/MSDS/64-69-7_MSDSC.htm" target="_blank"><?php echo $row_Recordset1['c_mads']; ?></a></p></td>
        </tr>
      </table>
    </form>
    </body>
    </html>
    <?php
    mysql_free_result($Recordset1);
    ?>
    我跳转的页面只这样的,,,现在只能输出固定的
      

  3.   


    <?phpheader('Content-Type: text/html; charset=gb2312');// 获取 表单提交过来的值 
    $select = empty($_POST['select'])?'':$_POST['select'];
    $chaxun = trim($_POST['chaxun']);
    $chaxun = empty($chaxun)?'':$chaxun;
    // 连接数据库
    mysql_connect("……");
    // 查询数据
    $sql = 'select * from table where ……';
    $query = mysql_query($sql);//自己看情况处理
    $res = mysql_fetch_array($query);
    // 输出 查询结果
    echo $res[0];?>
      

  4.   

    你只能输出固定的, 是因为 sql 语句 没 变 ,现在加上条件  ,改变 sql 语句就可以了where 条件看你怎么写了
      

  5.   

    不用另外弄 , 就是你的 a.php , 在前面 php 部分 加上  接收参数 ,改变 sql 语句 
      

  6.   

    你好 那sql里面的select * 和where *这个值怎么取啊?
      

  7.   

    我并不知道 你的表 结构 ,也不知道 你需要怎么查
    给个 例子$query_Recordset1 = "SELECT * FROM chanpinbiao where $select = '%{$chaxun}%' ";
      

  8.   

    "SELECT * FROM chanpinbiao where $select = '%{$chaxun}%' ";where后面的是刚刚那个下拉框的值怎么取啊?=号后面是文本框的值
      

  9.   


    // 获取 表单提交过来的值 
    $select = empty($_POST['select'])?'':$_POST['select'];
    $chaxun = trim($_POST['chaxun']);
    $chaxun = empty($chaxun)?'':$chaxun;
    $query_Recordset1 = "SELECT * FROM chanpinbiao where $select = '%{$chaxun}%' ";
    这样取 啊
     上面那个 sql  语句 应该没错
      

  10.   

    你可能没明白 , 用post 提交表单的值 , 会存在 $_POST 数组里面 ,我们 根据 名字 获取我们需要的 ,例如 $_POST['select'] , 然后赋值 给 我们自己的 变量 $select  , 这样我们就 可以 获取到自己 提交的值  了