在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
<!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> <h1>查询页面</h1> <form action="gjcchaxun.php" method="post"> <div> 请输入汽车名称: <input type="text" name="name" /> <input type="submit" value="查询" /> </div> </form> <table width="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td>代号</td> <td>名称</td> <td>系列</td> <td>上市时间</td> <td>油耗</td> <td>功率</td> </tr> <?php include("DBDA.class.php"); $db=new DBDA(); $tj=""; $name=""; if(!empty($_POST)) { $name=$_POST['name']; $tj="where Name like '%{$name}%'"; } $sql="select * from car ".$tj;//car后记得加空格 $attr=$db->Query($sql); foreach($attr as $v) { //处理关键字 $v[1];$name; //$re="<mark>{$name}</mark>"; $re="<span style='color:red'>{$name}</span>"; $str=str_replace($name,$re,$v[1]); echo"<tr> <td>{$v[0]}</td> <td>{$str}</td> <td>{$v[2]}</td> <td>{$v[3]}</td> <td>{$v[4]}</td> <td>{$v[5]}</td> </tr>"; } ?> </table> </body> </html>
<!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> <h1>查询页面</h1> <form action="duotiaojianchaxun.php" method="post"> <div> 请输入汽车名称: <input type="text" name="name" /> 请输入系列代号: <input type="text" name="brand"/> <input type="submit" value="查询" /> </div> </form> <table width="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td>代号</td> <td>名称</td> <td>系列</td> <td>上市时间</td> <td>油耗</td> <td>功率</td> </tr> <?php //一般来说做查询的时候,用户不输入任何内容就是查询所有的 include("DBDA.class.php"); $db=new DBDA(); //多条件查询 $tj1="1=1"; $tj2="1=1"; $name=""; if(!empty($_POST)) { if($_POST['name']!="") { $name=$_POST['name']; $tj1="Name like '%{$name}%'"; } if($_POST['brand']!="") { $tj2="Brand='{$_POST['brand']}'"; } } $cxtj=" where ".$tj1." and ".$tj2; $sql="select * from car ".$cxtj;//car后记得加空格 echo $sql; $attr=$db->Query($sql); foreach($attr as $v) { //处理关键字 $v[1];$name; //$re="<mark>{$name}</mark>"; $re="<span style='color:red'>{$name}</span>"; $str=str_replace($name,$re,$v[1]); echo"<tr> <td>{$v[0]}</td> <td>{$str}</td> <td>{$v[2]}</td> <td>{$v[3]}</td> <td>{$v[4]}</td> <td>{$v[5]}</td> </tr>"; } ?> </table> </body> </html>
|
2022-08-19
2022-07-30
2022-08-17
2022-11-06
2022-08-17
请发表评论