以下是一个例子:
html文件suggest.html:
<html>
<head>
<meta http-equiv="content-type" content="text/htmlcharset=UTF-8">
<script language="JavaScript" type="text/javascript" src="ajax_search.js"></script>
<style type="text/css" media="screen">
body {
font: 11px arial
}
.suggest_link {
background-color: #FFFFFF
padding: 2px 6px 2px 6px
cursor:hand
}
.suggest_link_over {
background-color: #E8F2FE
padding: 2px 6px 2px 6px
}
#search_suggest {
position:relative
background-color: #FFFFFF
text-align: left
border: 1px solid #000000
left: -12px
top: 1px
height: 74px
width: 170px
display:none
}
</style>
</head>
<body background="bg.gif">
<center>
<h3>实现搜索提示</h3>
<div style="width: 500px">
<input type="text" id="txtSearch" name="txtSearch" onKeyUp="searchSuggest()" autocomplete="off" />
<input type="submit" id="cmdSearch" name="cmdSearch" value="搜索"/><br />
<div id="search_suggest"></div>
</div>
</center>
</body>
</html>
ajax_search.js:
var searchReq = createAjaxObj()
function createAjaxObj()
{
var httprequest=false
if (window.XMLHttpRequest) //为非IE浏览器生成XmlHttpRequest对象
{
httprequest=new XMLHttpRequest()
if (httprequest.overrideMimeType) httprequest.overrideMimeType('text/xml')
}
else if (window.ActiveXObject) //为IE浏览器生成XmlHttpRequest对象
{
try
{
httprequest=new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e)
{
try
{
httprequest=new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
return httprequest
}
function searchSuggest()
{
if (searchReq.readyState == 4 || searchReq.readyState == 0)
{
1、导入.sql文件命令:mysql>use
数据库名mysql>
source
d:/mysql.sql
2、建立数据库:mysql>
create
database
库名
3、建立数据表:mysql>
use
库名mysql>
create
table
表名
(字段名
varchar(20),
字段名
char(1))
4、删除数据库:mysql>
drop
database
库名
5、删除数据表:mysql>
drop
table
表名;
6、将表中记录清空:mysql>
delete
from
表名
7、往表中插入记录:mysql>
insert
into
表名
values
("hyq","m")
8、更新表中数据:mysql->
update
表名
set
字段名1='a',字段名2='b'
where
字段名3='c'
9、用文本方式将数据装入数据表中:mysql>
load
data
local
infile
"d:/mysql.txt"
into
table
表名