zoukankan      html  css  js  c++  java
  • 查询图书价格php+ mysql

    <html>
    <head><meta charset="utf-8"></head>
    <body>
    <h1>图书查询系统</h1>
    <form action="" method="post">
    <input type="radio" value='no' name='xuanze'>图书编号
    <input type="radio" value='name' name='xuanze'>书名
    <input type='radio' value='author' name='xuanze'>作者<br><br>
    请输入已知信息:<input type="text" name="nu"><br><br>
    <input type="submit">
    </form>
    <table border="1">
    <?php
    @$nu=$_POST['nu'];
    $sql=mysql_connect('localhost','root','admin');//连接打开数据库
    mysql_select_db('shudian',$sql);


    $ziduan=mysql_list_fields('shudian','shu');//取出表中的字段,以表格方式显示。
    $num=mysql_num_fields($ziduan);
    echo "<tr>";
    for($i=0;$i<$num;$i++)

    {
      $dd=mysql_field_name($ziduan,$i);
      echo "<td>".$dd."</td>";
    }
    echo "</tr>";


    if(@$_POST['xuanze']=='no')//判断表单的查询方式

    {

      $command="select * from shu where sno like '%".$nu."%'";//设置查询命令
      $file=mysql_query($command,$sql) or die(mysql_error);

    }
    else if(@$_POST['xuanze']=='name')

    {
      $command="select * from shu where sname like '%".$nu."%'";
      $file=mysql_query($command,$sql) or die(mysql_error);

    }
    else{
      $command="select * from shu where author like '%".$nu."%'";
      $file=mysql_query($command,$sql) or die(mysql_error);

      }


    while($array=mysql_fetch_array($file,MYSQL_NUM))//以表格形式输出信息

    {
     echo "<tr>";
     for($i=0;$i<count($array);$i++)
     {echo "<td>".$array[$i]."</td>";}
     echo "</td>";
    }
    ?>
    </table>
    </body>
    </html>

  • 相关阅读:
    ecplise中修改reviewboard密码
    本地上jar命令
    Python面试必须要看的15个问题
    Maven命令行窗口指定settings.xml
    codevs1002搭桥(建图+Prim)
    codevs1099字串变换(Bfs)
    codevs1044四子连棋(Dfs)
    codevs1226倒水问题(Bfs)
    codevs1051单词接龙(栈)
    niop 2014寻找道路
  • 原文地址:https://www.cnblogs.com/anqi/p/3296158.html
Copyright © 2011-2022 走看看