<%
Function b(byref a)
dim con,strsql,rec
set con = Server.CreateObject("ADODB.Connection")
con.open "DRIVER={MySQL ODBC 5.1 Driver}; SERVER=localhost;UID=root;pwd=admin;database=med;option=16384;"
strsql = "Select * from news,officer where newstype like '%" & a & "%' and news.of_username=officer.of_username "
set rec=Server.CreateObject("ADODB.Recordset")
rec.open strsql,con
If rec.EOF then
Response.write("Not Found")
End if
%>
<table border="0" width="790">
<tr>
<th bgcolor="#0066CC"><div align="center" style="color:#FFFFFF" >วันที่ประกาศ</div></th>
<th bgcolor="#0066CC"><div align="center" style="color:#FFFFFF">หัวข้อ</div></th>
<th bgcolor="#0066CC"><div align="center" style="color:#FFFFFF">ผู้ประกาศ</div></th>
</tr>
<%
if a="ข่าวทั่วไป" then
dim z
while not rec.EOF
%>
<tr>
<td width="200"><div align="center"><%=rec.fields("ddate").value%></div></td>
<td width="400"><div align="center"><div align="left"><a href="newreport.asp?newid=<%=rec.fields("newsid").value%>" target="_blank" onclick="openWindow()"><%=rec.Fields("title").Value%></a></div></div></td>
<td width="190"><div align="center"><%=rec.fields("of_name").value%></div></td>
<%
z=rec.fields("newstype").value
rec.movenext
wend
%>
<tr><td colspan="3">
<div align="right"><a href="newall.asp?newty=<%=Server.URLEncode("ข่าวทั่วไป")%>"> ดูทั้งหมด</a>
</div></td></tr>
<%
elseif a="ข่าวประกาศ" then
while not rec.EOF
%>
<tr>
<td width="200"><div align="center"><%=rec.fields("ddate").value%></div></td>
<td width="400"><div align="center"><div align="left"><a href="newcall.asp?newcid=<%=rec.fields("newsid").value%>" target="_blank" onclick="openWindow()"><%=rec.Fields("title").Value%></a></div></div></td>
<td width="190"><div align="center"><%=rec.fields("of_name").value%></div></td>
</tr>
<%
rec.movenext
wend
%>
<tr><td colspan="3">
<div align="right"><a href="newall.asp?newty=<%=Server.URLEncode("ข่าวประกาศ")%>"> ดูทั้งหมด</a>
</div></td></tr>
<%
elseif a="ข่าวกิจกรรม" then
while not rec.EOF
%>
<tr>
<td width="200"><div align="center"><%=rec.fields("ddate").value%></div></td>
<td width="400"><div align="center"><div align="left"><a href="newactivity.asp?newaid=<%=rec.fields("newsid").value%>" target="_blank" onclick="openWindow()"><%=rec.Fields("title").Value%></a></div></div></td>
<td width="190"><div align="center"><%=rec.fields("of_name").value%></div></td>
</tr>
<%
rec.movenext
wend
%>
<tr><td colspan="3">
<div align="right"><a href="newall.asp?newty=<%=Server.URLEncode("ข่าวกิจกรรม")%>"> ดูทั้งหมด</a>
</div></td></tr>
<%
elseif a="ก่อนปริญญา" then
while not rec.EOF
%>
<tr>
<td width="200"><div align="center"><%=rec.fields("ddate").value%></div></td>
<td width="400"><div align="center"><div align="left"><a href="newbefore.asp?newbid=<%=rec.fields("newsid").value%>" target="_blank" onclick="openWindow()"><%=rec.Fields("title").Value%></a></div></div></td>
<td width="190"><div align="center"><%=rec.fields("of_name").value%></div></td>
</tr>
<%
rec.movenext
wend
%>
<tr><td colspan="3">
<div align="right"><a href="newall.asp?newty=<%=Server.URLEncode("ก่อนปริญญา")%>"> ดูทั้งหมด</a>
</div></td></tr>
<%
else
while not rec.EOF
%>
<tr>
<td width="200"><div align="center"><%=rec.fields("ddate").value%></div></td>
<td width="400"><div align="center"><div align="left"><a href="newafter.asp?newfid=<%=rec.fields("newsid").value%>" target="_blank" onclick="openWindow()"><%=rec.Fields("title").Value%></a></div></div></td>
<td width="190"><div align="center"><%=rec.fields("of_name").value%></div></td>
</tr>
<%
rec.movenext
wend
%>
<tr><td colspan="3">
<div align="right"><a href="newall.asp?newty=<%=Server.URLEncode("หลังปริญญา")%>"> ดูทั้งหมด</a>
</div></td></tr>
<%
end if
%>
</table>
<%
'end If
rec.close()
con.close()
set rec=nothing
set con=nothing
End Function
%>
newall.asp(ASP)
<!--#include file="header.asp"-->
<!--#include file="menu.asp"-->
<td valign="top" class="f2">
<table border="0" ><tr><td width="790" align="right">
<form action="newsearch.asp" method="post">
<input name="txtsearch" type="text" />
<input name="search" type="submit" value="ค้นหา" />
</form></td></tr></table>
<%
dim con,strsql,rec,lu
lu=newty
set con = Server.CreateObject("ADODB.Connection")
con.open "DRIVER={MySQL ODBC 5.1 Driver}; SERVER=localhost;UID=root;pwd=admin;database=med;option=16384;"
strsql = "Select * from News,officer where title like '%"& Request.QueryString("newty") &"%' and news.of_username=officer.of_username "
set rec=Server.CreateObject("ADODB.Recordset")
rec.open strsql,con
If rec.EOF then
'Response.write("Not Found")
End if
'Paging
dim pagelen,pageno,totalrecord,totalpage,intID
dim pagestart,pageend
pagelen=10
pageno=Request.QueryString("Page")
if pageno = "" then pageno = 1
totalrecord= UBound(rec.GetRows,2)+1
pagestart=((pagelen*pageno)-pagelen)
pageend=pagelen
if totalrecord<=pagelen then
totalpage=1
elseif (totalrecord Mod pagelen =0) then
totalpage=(totalrecord/pagelen)
else
totalpage=(totalrecord/pagelen)+1
totalpage=cint(totalpage)
end if
'colse object and open new record set
rec.close()
strsql= strsql&"ORDER BY newsid ASC LIMIT "&pagestart&","&pageend&""
rec.open strsql,con
%>
<table border="0" width="790">
<tr>
<th bgcolor="#0066CC"><div align="center" style="color:#FFFFFF" >วันที่ประกาศ</div></th>
<th bgcolor="#0066CC"><div align="center" style="color:#FFFFFF">หัวข้อ</div></th>
<th bgcolor="#0066CC"><div align="center" style="color:#FFFFFF">ผู้ประกาศ</div></th>
</tr>
<%
Response.Write(strsql)
while not rec.EOF
%>
<tr>
<td width="200"><div align="center"><%=rec.fields("ddate").value%></div></td>
<%
if rec.fields("newstype")="ข่าวทั่วไป" or rec.fields("newstype")="ข่าวประกาศ" then
%>
<td width="400"><div align="center"><div align="left"><a href="newreport.asp?newid=<%=rec.fields("newsid").value%>" target="_blank" onclick="openWindow()"><%=rec.Fields("title").Value%></a></div></div></td>
<%
elseif rec.fields("newstype")="ข่าวกิจกรรม" then
%>
<td width="400"><div align="center"><div align="left"><a href="newactivity.asp?newaid=<%=rec.fields("newsid").value%>" target="_blank" onclick="openWindow()"><%=rec.Fields("title").Value%></a></div></div></td>
<%
elseif rec.fields("newstype")="ข่าวการศึกษาก่อนปริญญา" then
%>
<td width="400"><div align="center"><div align="left"><a href="newbefore.asp?newbid=<%=rec.fields("newsid").value%>" target="_blank" onclick="openWindow()"><%=rec.Fields("title").Value%></a></div></div></td>
<%
else
%>
<td width="400"><div align="center"><div align="left"><a href="newafter.asp?newfid=<%=rec.fields("newsid").value%>" target="_blank" onclick="openWindow()"><%=rec.Fields("title").Value%></a></div></div></td>
<%
end if
%>
<td width="190"><div align="center"><%=rec.fields("of_name").value%></div></td>
</tr>
<%
rec.movenext
wend
%>
</table>
หน้าที่ <%=pageno%>
<% if cint(pageno) > 1 then %>
<a href="<%Request.ServerVariables("SCRIPT_NAME")%>?page=1>"><<หน้าแรก</a>
<a href="<%Request.ServerVariables("SCRIPT_NAME")%>?page=<%=pageno-1%>">< ก่อนหน้า</a>
<% End if %>
<% if cint(pageno)<totalpage then %>
<a href="<%Request.ServerVariables("SCRIPT_NAME")%>?page=<%=pageno+1%>">ถัดไป ></a>
<a href="<%Request.Servervariables("SCRIPT_NAME")%>?page=<%=totalpage%>">หน้าสุดท้าย >></a>
<% End if %>
<br />
<% For IntID = 1 to totalpage
if intID= cint(pageno) then
%>
<b><%=intID%></b>
<% else %>
<a href="<%Request.ServerVariables("SCRIPT_NAME")%>?page=<%=intID%>"><%=intID%></a>
<% End if
next
%>
<%
'end If
rec.close()
con.close()
set rec=nothing
set con=nothing
%>
</td>
</tr>
</table>
<!--#include file="footer.asp"-->