<% Dim Connect, rstemp, sqlString, connstr Set Connect = Server.CreateObject("ADODB.Connection") connstr = "Driver={Mysql}; Server=sql4de.your-server.co.za; Database=namibi_db1; UID=namibi_u1_r; PWD=qtzffgdT;" Connect.Open(connstr) sqlString = "SELECT * FROM Lesotho WHERE Id = '1' ORDER BY Category ASC" Set rstemp = Connect.Execute(sqlString) if rstemp.eof then response.write "no data for
" response.write sqlString Connect.close set Connect=nothing response.end end if %> Lesotho Internet Directory - Search Results
Welcome to Lesothointernetdirectory.com <%=FormatDateTime(Date,1) %>   <%=FormatDateTime(now,3) %>


<% dim filename filename = "hit_count.txt" Set fs=Server.CreateObject("Scripting.FileSystemObject") 'open the file Set f=fs.OpenTextFile(Server.MapPath(filename), 1) content = f.ReadAll If content = "" Then content = 0 End If 'close the file f.Close 'empty the objects Set f=Nothing Set fs=Nothing %> Hit Count: <% Response.Write(content)%>
Online Users:<% Response.Write(Application("online_users"))%>
<% dim strconn strconn = "Driver={Mysql}; Server=sql4de.your-server.co.za; Database=namibi_db1; UID=namibi_u1_r; PWD=qtzffgdT;" Set objConn = Server.CreateObject ("ADODB.Connection") objConn.open strconn Set Rec = objConn.execute("Select count(*) from Lesotho") %>Current Listings:<%= Rec(0) %>

Username:

Password:

<% ' BEGIN USER CONSTANTS Dim CONN_STRING CONN_STRING = "Driver={Mysql}; Server=sql4de.your-server.co.za; Database=namibi_db1; UID=namibi_u1_r; PWD=qtzffgdT;" ' END USER CONSTANTS ' BEGIN RUNTIME CODE ' Declare our vars Dim iPageSize 'How big our pages are Dim iPageCount 'The number of pages we get back Dim iPageCurrent 'The page we want to show Dim strSearch 'A fake parameter used to illustrate passing them Dim strSQL 'SQL command to execute Dim objPagingConn 'The ADODB connection object Dim objPagingRS 'The ADODB recordset object Dim iRecordsShown 'Loop controller for displaying just iPageSize records Dim I 'Standard looping var ' Get parameters iPageSize = 3 ' You could easily allow users to change this ' Retrieve page to show or default to 1 If Request.QueryString("page") = "" Then iPageCurrent = 1 Else iPageCurrent = CInt(Request.QueryString("page")) End If ' If you're doing this script with a search or something ' you'll need to pass the sql from page to page. I'm just ' paging through the entire table so I just hard coded it. ' What you show is irrelevant to the point of the sample. 'strSQL = "SELECT * FROM sample ORDER BY id;" ' Sept 30, 1999: Code Change ' Based on the non stop questions about how to pass parameters ' from page to page, I'm implementing it so I can stop answering ' the question of how to do it. I personally think this should ' be done based on the specific situation and is clearer if done ' in the same method on all pages, but it's really up to you. ' I'm going to be passing the ORDER BY parameter for illustration. ' This is where you read in parameters you'll need for your query. ' Read in order or default to id 'If Request.QueryString("order") = "" Then ' strOrderBy = "id" 'Else ' strOrderBy = Replace(Request.QueryString("order"), "'", "''") 'End If ' Make sure the input is one of our fields. strSearch = Request.QueryString("keywords") if strSearch = "" then strSearch = "id" else strSearch = Replace(Request.QueryString("keywords"), "'", "' '") end if ' Build our SQL String using the parameters we just got. strSQL = "SELECT * FROM Lesotho Where Company_Name Like '%" & strSearch & "%' OR Category like '%" & strSearch & "%' ORDER BY Company_Name ASC" ' Some lines I used while writing to debug... uh "test", yeah that's it! ' Left them FYI. 'strSQL = "SELECT * FROM sample WHERE id=1234 ORDER BY id;" 'strSQL = "SELECT * FROM sample;" 'Response.Write "SQL Query: " & strSQL & "
" & vbCrLf ' Now we finally get to the DB work... ' Create and open our connection Set objPagingConn = Server.CreateObject("ADODB.Connection") objPagingConn.Open CONN_STRING ' Create recordset and set the page size Set objPagingRS = Server.CreateObject("ADODB.Recordset") objPagingRS.PageSize = iPageSize ' You can change other settings as with any RS 'objPagingRS.CursorLocation = adUseClient objPagingRS.CacheSize = iPageSize ' Open RS objPagingRS.Open strSQL, objPagingConn, 3, 1, &H0001 ' Get the count of the pages using the given page size iPageCount = objPagingRS.PageCount ' If the request page falls outside the acceptable range, ' give them the closest match (1 or max) If iPageCurrent > iPageCount Then iPageCurrent = iPageCount If iPageCurrent < 1 Then iPageCurrent = 1 ' Check page count to prevent bombing when zero results are returned! If iPageCount = 0 Then Response.Write "No records found!" Else ' Move to the selected page objPagingRS.AbsolutePage = iPageCurrent ' Start output with a page x of n line %>
Displaying Page <%= iPageCurrent %> of <%= iPageCount %>

<% iRecordsShown = 0 Do While iRecordsShown < iPageSize And Not objPagingRS.EOF %>
<%=objPagingRS("Company_Name")%>
<% If objPagingRS("Physical_Address") = "N/A" Then %> <% Else %> Physical Address: <%=objPagingRS("Physical_Address")%>
<% End If %> <% If objPagingRS("Postal_Address") = "N/A" Then %> <% Else %> Postal Address: <%=objPagingRS("Postal_Address")%>
<% End If %> <% If objPagingRS("Telephone") = "N/A" Then %> <% Else %> Telephone: <%=objPagingRS("Telephone")%>
<% End If %> <% If objPagingRS("Fax") = "N/A" Then %> <% Else %> Fax: <%=objPagingRS("Fax")%>
<% End If %> <% If objPagingRS("Cellular") = "N/A" Then %> <% Else %> Cellular: <%=objPagingRS("Cellular")%>
<% End If %> <% If objPagingRS("Email") = "N/A" Then %> <% Else %> Email: ">
<% End If %> <% If objPagingRS("Website") = "N/A" Then %> <% Else %> Website: " target = "_blank">
<% End If %> <% If objPagingRS("Advert") = "N/A" Then %> <% Else %> Advert: " target = "_blank">
<% End If %> Listing Category: <%=objPagingRS("Category")%>
 


<% ' Increment the number of records we've shown iRecordsShown = iRecordsShown + 1 ' Can't forget to move to the next record! objPagingRS.MoveNext Loop End If ' Close DB objects and free variables objPagingRS.Close Set objPagingRS = Nothing objPagingConn.Close Set objPagingConn = Nothing ' Show "previous" and "next" page links which pass the page to view ' and any parameters needed to rebuild the query. You could just as ' easily use a form but you'll need to change the lines that read ' the info back in at the top of the script. %>
Home <% If iPageCurrent > 1 Then %> [<< Prev] <% End If ' You can also show page numbers: For I = 1 To iPageCount If I = iPageCurrent Then %> <%= I %> <% Else %> <%= I %> <% End If Next 'I If iPageCurrent < iPageCount Then %> [Next >>] <% End If ' END RUNTIME CODE %>



Excellent
Very Good
Good
Average
Poor