ครั้งแรกที่สร้างฐานข้อมูลการเข้าถึง
| ต่อไปนี้เป็นเนื้อหาอ้างอิง: ข้อความ URL (ดัชนี: มี (ไม่มีการทำซ้ำ)) ข้อความชื่อเรื่อง ข้อความอธิบาย ข้อความสรุป ข้อความคำหลัก (ดัชนี: มี (ไม่มีการทำซ้ำ)) |
ไฟล์โปรแกรม doQuery.asp, รหัส:
| ต่อไปนี้เป็นเนื้อหาอ้างอิง: <Html> <head> <title> เครื่องมือค้นหาง่าย ๆ </title> </head> <bodybgcolor =#fffffffffmarginWidth = 0MarginHeight = 0 leftmargin = 0TopMargin = 0> <formMethod = postaction = doQuery.asp? แบบสอบถาม: <putType = textName = QueryString> <br> <inputType = submentValue = ส่ง> </form> </enter> - สลัว Act = คำขอ (พระราชบัญญัติ) if (act = search) จากนั้น QueryString = request.form (QueryString) querywords = split (querystring) strindent = 'หากการค้นหาว่าง ifQueryString = จากนั้น Response.redirect (default.asp) endif session.timeout = 2 ifisObject (เซสชัน (siteSearch_conn) จากนั้น) จากนั้น setConn = เซสชัน (siteSearch_conn) อื่น setConn = server.createObject (adodb.connection) conn.opendriver = {microsoftaccessDriver (*. mdb)}; SetSession (siteSearch_conn) = Conn endif คำสั่งค้นหา sql = select*จาก [urlindex] ที่ไหน 'ค้นหาฟิลด์คำอธิบาย sql = sql & ([คำอธิบาย] เช่น '%& Querywords (0) &%' ก่อน fori = lbound (querywords)+1toubound (querywords) ifQuerywords (i) <> Anducase (Querywords (i)) <> Orangewords (i)) ifucase (querywords (i-1)) = orthen sql = sql & หรือ [คำอธิบาย] เช่น '%& Querywords (i) &%' อื่น SQL = SQL & และ [คำอธิบาย] เช่น '%& Querywords (i) &%' endif endif ต่อไป 'ฟิลด์คำหลักค้นหา sql = sql &) หรือ ([คำหลัก] เช่น '%& Querywords (0) &%' fori = lbound (querywords)+1toubound (querywords) ifQuerywords (i) <> Anducase (Querywords (i)) <> Orangewords (i)) ifucase (querywords (i-1)) = orthen SQL = SQL & หรือ [คำหลัก] เช่น '%& Querywords (i) &%' อื่น SQL = SQL & และ [คำหลัก] เช่น '%& Querywords (i) &%' endif endif ต่อไป 'ฟิลด์ชื่อค้นหา sql = sql &) หรือ ([ชื่อ] เช่น '%& Querywords (0) &%' fori = lbound (querywords)+1toubound (querywords) ifQuerywords (i) <> Anducase (Querywords (i)) <> Orangewords (i)) ifucase (querywords (i-1)) = orthen sql = sql & หรือ [title] เช่น '%& Querywords (i) &%' อื่น sql = sql & และ [title] เช่น '%& Querywords (i) &%' endif endif ต่อไป 'ฟิลด์สรุปการค้นหา sql = sql &) หรือ ([สรุป] เช่น '%& Querywords (0) &%' fori = lbound (querywords)+1toubound (querywords) ifQuerywords (i) <> Anducase (Querywords (i)) <> Orangewords (i)) ifucase (querywords (i-1)) = orthen SQL = SQL & หรือ [สรุป] เช่น '%& Querywords (i) &%' อื่น SQL = SQL & และ [สรุป] เช่น '%& Querywords (I) &%' endif endif ต่อไป SQL = SQL &) - setRs = server.createObject (adoDb.oldset) Rs.opensql, Conn, 3,3 Response.write <br> <b> สิ่งที่คุณค้นหาคือ: </b> & QueryString Response.write <br> <b> คำหลักค้นหา: </b> fori = lbound (querywords) toubnsnd (querywords) Response.write <br> & strindent & i &: & querywords (i) ต่อไป 'printthesqlstring Response.write <br> <b> คำสั่ง SQL: </b> & sql 'printtheresults Response.write <br> <b> ผลลัพธ์: </b> <ul> onerrersumenext Rs.movefired dowhilenotrs.eof Response.write <br> & <ahref = 'OpenPage.asp? Response.writers.fields (คำอธิบาย) & <br> response.write <fontsize = 2> url: & rs.fields (url) & </font> Response.write <hrsize = 1Width = 200Alig Rs.Movenext วง Response.write </ul> endif - </body> </html> |