Lars Grove Mortensen wrote in
dk.edb.internet.webdesign.serverside.asp:
> Hej alle
>
> I forbindelse med udarbejdelsen af et alfabetisk-ordnet register,
> skal jeg have det lavet således, at der vil være en oversigt over
> alfabetet - og når man eksempelvis trykker på "A" skal systemet
> hente alle de poster fra databasen, hvor feltet "Navn" har
> forbogstavet "A"...
>
> Hvordan gøres det?
>
Godt nok lidt sent at svare men jeg gør sådan her....
<%
response.write "<bgcolor=""#000080"">"
Set DataConn = Server.CreateObject("ADODB.Connection")
DataConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" &
Server.MapPath("Database.mdb") & ""
SQL = "Select * From Billeder where nick like '" &
request.form("qrt") & "%'"
Set RS = DataConn.Execute(SQL)
If (RS.EOF Or RS.BOF) = "" Then
Response.Write"Der er ingen billeder i databasen."
Else
' *************** Gennemløb Recordset (rs) med en løkke
******************
Dim strlink, ItemCounter, kol, wide, strvalg
kol = 4 'Antalet af kolloner
ItemCounter = 0
wide = 25
Response.Write "<Center><table border=""1"" align=""center""
width=""100%""
bgcolor=""#800080"">"
Response.Write "<tr>"
Do
' *************** laver et link til andre.asp med Id-værdien i
URL
**************************
strLink = "<img src=""vis_billede.asp?id=" & rs("id") & """
width=""160""
height=""120""></a>"
strvalg = "<a href='valg.asp'></a>"
' *************** Liste med links ******************
Response.Write "<td align=""center"" width="" " &
CInt(100/kol) & "%""> " &
strLink & "<br><p align=""left"">" & "Nick: " & "" & rs("nick") &
"<br><p align=""left"">" &
"Irl: " & "" & rs("irl") & "</td>"
' *************** Gå til næste Record i rs ******************
rs.MoveNext
'******* Skift line for hver 4. link *******************
If (ItemCounter Mod kol) = (kol-1) Then
response.write "</tr></table><br><table border=""1""
align=""center"" width=""100%""><tr>"
End If
ItemCounter=ItemCounter+1
'if wide = 100 then wide = 0
'end if
'wide = wide+25
' *************** Fortsæt indtil rs er gennemløbet (EOF = End Of
File)
*****************
Loop While Not rs.EOF
'********* Afslutter tabel ***************
Response.Write "</tr></table></center>"
<!--#include virtual=/wwwroot/valg.asp-->
end if
response.write "<br><div align=""center""><center><table
border=""1"" width=""100%""
bgcolor=""#800080""><tr><td width=""25%"" align=""center""
valign=""middle""
height=""30""><form method=""post"" action=""opret.asp""><input
class=knap type=""submit""
value=""opret mig"" Name=""qrt"" valign=""middle""></form><form
method=""post""
action=""se.asp""><input class=knap type=""submit"" value=""a""
Name=""qrt""
valign=""middle""><input class=knap type=""submit"" value=""b""
name=""qrt""><input
class=knap type=""submit"" value=""c"" name=""qrt""><input
class=knap type=""submit""
value=""d"" name=""qrt""><input class=knap type=""submit""
value=""e"" name=""qrt""><input
class=knap type=""submit"" value=""f"" name=""qrt""><input
class=knap type=""submit""
value=""g"" name=""qrt""><input class=knap type=""submit""
value=""h"" name=""qrt""><input
class=knap type=""submit"" value=""i"" name=""qrt""><input
class=knap type=""submit""
value=""j"" name=""qrt""><input class=knap type=""submit""
value=""k"" name=""qrt""><input
class=knap type=""submit"" value=""l"" name=""qrt""><input
class=knap type=""submit""
value=""m"" name=""qrt""><input class=knap type=""submit""
value=""n"" name=""qrt""><input
class=knap type=""submit"" value=""o"" name=""qrt""><input
class=knap type=""submit""
value=""p"" name=""qrt""><input class=knap type=""submit""
value=""q"" name=""qrt""><input
class=knap type=""submit"" value=""r"" name=""qrt""><input
class=knap type=""submit""
value=""s"" name=""qrt""><input class=knap type=""submit""
value=""t"" name=""qrt""><input
class=knap type=""submit"" value=""u"" name=""qrt""><input
class=knap type=""submit""
value=""v"" name=""qrt""><input class=knap type=""submit""
value=""x"" name=""qrt""><input
class=knap type=""submit"" value=""y"" name=""qrt""><input
class=knap type=""submit""
value=""z"" name=""qrt""><input class=knap type=""submit""
value=""æ"" name=""qrt""><input
class=knap type=""submit"" value=""ø"" name=""qrt""><input
class=knap type=""submit""
value=""å"" name=""qrt""><input class=knap type=""submit""
value=""0-9""
name=""qrt""></form><form method=""post""
action=""default.asp""><input class=knap
type=""submit"" value=""til start"" Name=""qrt""
valign=""middle""></td></tr></table></center></div>"
RS.Close
Set RS = Nothing
DataConn.Close
Set DataConn = Nothing
%>
mvh.
René
--
Vil du lære at kode HTML, XHTML, CSS, SSI eller ASP ???
- Pædagogiske tutorials på dansk
- Kom godt i gang med koderne
KLIK HER! =>
http://www.html.dk/tutorials