zoukankan      html  css  js  c++  java
  • 查询

    <?php
    include "./dbda.class.php";
    $db = new dbda();
    $sql1 = "";
    $value = "";
    if(!empty($_POST["name"]))
    {
    $name = $_POST["name"];
    $sql1 = " where Name like '%{$name}%'";
    $value = $name;
    }
    ?>
    <h1>汽车查询界面</h1>
    <form action="chaxun.php" method="post">
    <div>请输入名称:<input type="text" name="name" value="<?php echo $value;?>" />&nbsp;<input type="submit" value="查询" /></div>
    </form>
    <br />
    <table width="100%" border="1" cellpadding="0" cellspacing="0">
    <tr>
    <td>代号</td>
    <td>名称</td>
    <td>油耗</td>
    <td>功率</td>
    <td>价格</td>
    </tr>
    <?php
    $sql = "select * from car".$sql1;
    $attr = $db->Query($sql);
    foreach($attr as $v)
    {
    $a = "<span style='color:red'>{$value}</span>";
    $str = str_replace($value,$a,$v[1]);
    echo "<tr>
    <td>{$v[0]}</td>
    <td>{$str}</td>
    <td>{$v[4]}</td>
    <td>{$v[5]}</td>
    <td>{$v[7]}</td>
    </tr>";
    }


    ?>

    </table>

    <?php
    class dbda
    {
    public $host = "localhost";
    public $uid = "root";
    public $pwd = "";

    public function Query($sql,$type=0,$db="mydb")
    {
    $d = new MySQLi($this->host,$this->uid,$this->pwd,$db);
    !mysqli_connect_error() or die("连接失败!");
    $result = $d->query($sql);
    if($type==0)
    {
    return $result->fetch_all();
    }
    else
    {
    return $result;
    }
    }
    }

  • 相关阅读:
    c++ Oracle OCCI 编程
    linux库文件
    C/C++学习笔记 vector 和map基本操作总结
    linux 后台开发类常见问题及知识点
    Libmicrohttpd简介
    linux系统编程之进程(一):进程与程序
    回调函数
    va_start和va_end使用详解
    new在c#方法中的使用
    Android Studio快捷键
  • 原文地址:https://www.cnblogs.com/1116zsc/p/5470538.html
Copyright © 2011-2022 走看看