一个用mysql_odbc和php写的serach数据库程序

 1<html>
 2<head>
 3<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
 4<title>查询条件</title>
 5<meta content="Microsoft FrontPage 3.0" name="GENERATOR"/>
 6</head>
 7<body bgcolor="#fcf8c2">
 8<p>查询条件 </p>
 9<form action="searchyh.php" method="post">
10<table border="1" height="34" width="43%">
11<tr>
12<td height="28" width="100%">用户名称: <input name="name" size="20" type="text"/></td>
13<td height="28" width="100%">用户地址: <input name="add" size="20" type="text"/></td>
14<td height="28" width="100%">用户电话: <input name="tel" size="20" type="text"/></td>
15</tr>
16</table>
17<p><input type="submit" value="提交查询"/> </p>
18</form>
19</body>
20</html>

//后台PHP

1   
2echo "

<body bgcolor="’#fcf8c2’">";
echo "查询结果:";
echo "
";
echo "
";
$conn = odbc_connect("blue", "root", "");
$name .="%";
$add .="%";
$tel .="%";
$query = "select * ";
$query .= "from jc_yh where (name like ’$name’ and address like’$add’ and tel like ’$tel’ )";
odbc_result_all( odbc_do($conn, $query), "border=1 width=50%");
odbc_close($conn);

 1  
 2///表结构   
 3CREATE TABLE jc_yh (   
 4id int not null default 0,   
 5name varchar(80) not null default "blue",   
 6city varchar(40) not null default "xn",   
 7tel varchar(14) not null default "00000000000000",   
 8fax varchar(14) not null default "00000000000000",   
 9address varchar(60) not null default "xn",   
10post varchar(6) not null default "000000");</body>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus