"Sider" med MySQL
Hej eksperter!Jeg skal have lavet et script hvor du bruger "sider" (altså så du kan vælge fx hvis der er 12 så er der 2 sider ... dvs at den skal vise 10 records pr. side)
Jeg brugte denne kode til access databaser:
<table bgcolor="#A1B17B" border="0" align="left" cellpadding="0" cellspacing="0" width="410">
<tr>
<td width="15" bgcolor="A1B17B" style="border-top: 1px solid #A1B17B; border-right: 1px solid #A1B17B;" align="center"><span class="MainText" style="color: #FFFFFF;">¤</span></td>
<td width="175" bgcolor="A1B17B" style="border-top: 1px solid #A1B17B;"><span class="MainText" style="color: #FFFFFF;"> Question</span></td>
<td width="55" bgcolor="A1B17B" style="border-top: 1px solid #A1B17B; border-right: 1px solid #A1B17B;"><span class="MainText" style="color: #FFFFFF;"> Points</span></td>
<td width="110" bgcolor="A1B17B" style="border-top: 1px solid #A1B17B; border-right: 1px solid #A1B17B;"><span class="MainText" style="color: #FFFFFF;"> Created</span></td>
<td width="55" bgcolor="A1B17B" style="border-top: 1px solid #A1B17B;"><span class="MainText" style="color: #FFFFFF;"> Answers</span></td>
</tr>
<%
intPage = Request("page")
if isNumeric(intPage) = False or intPage < 1 then
intPage = 1
end if
if Request("page") = "" then
intPage = 1
end if
Set rs = Server.CreateObject("ADODB.RecordSet")
strSQL = "SELECT * FROM ForumSpm WHERE KatBesk='" & kat("KatBesk") & "' AND Besvaret='Yes' ORDER BY id desc"
strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db.mdb")
rs.Open strSQL, strDSN, 1
if rs.EOF then
%>
<tr>
<td width="15" bgcolor="E1EBC9" style="border-top: 1px solid #A1B17B; border-right: 1px solid #A1B17B;"></td>
<td width="175" bgcolor="EBF0E0" style="border-top: 1px solid #A1B17B;"><span class="MainText"> No questions here :o)</span></td>
<td width="55" bgcolor="EBF0E0" style="border-top: 1px solid #A1B17B; border-right: 1px solid #A1B17B;"></td>
<td width="110" bgcolor="EBF0E0" align="center" style="border-top: 1px solid #A1B17B; border-right: 1px solid #A1B17B;"></td>
<td width="55" bgcolor="EBF0E0" style="border-top: 1px solid #A1B17B;"></td>
</tr>
<%
else
if not (rs.eof or rs.bof) then
rs.PageSize = 10
rs.AbsolutePage = intPage
intRecCount = rs.PageSize
intPageCount = rs.PageCount
do while not rs.eof and intRecCount > 0
%>
<tr>
<td width="15" bgcolor="E1EBC9" style="border-top: 1px solid #A1B17B; border-right: 1px solid #A1B17B;" align="center"><span class="MainText"><img src="./images/fstatus3.jpg" border="0" width="9" height="9"></span></td>
<td width="175" bgcolor="EBF0E0" style="border-top: 1px solid #A1B17B;"><span class="MainText"> <a href="./question.asp?id=<%=rs("id")%>"<% if Len(rs("Spm")) > 30 then %> title="<%=rs("Spm")%>" class="MainLink01"><%= left(rs("Spm"), 30)%>...<% else %> class="MainLink01"><%=rs("Spm")%><% end if %></a></span></td>
<td width="55" bgcolor="EBF0E0" style="border-top: 1px solid #A1B17B; border-right: 1px solid #A1B17B;" align="right"><span class="MainText"><%=rs("Points")%> </span></td>
<td width="110" bgcolor="EBF0E0" align="center" style="border-top: 1px solid #A1B17B; border-right: 1px solid #A1B17B;"><span class="MainText">06-03-2002 15:07:06</span></td>
<td width="55" bgcolor="EBF0E0" style="border-top: 1px solid #A1B17B;"><span class="MainText"> <%=rs("Indlaeg")%></span></td>
</tr>
<%
intRecCount = intRecCount - 1
rs.MoveNext
loop
end if
end if
%>
<tr>
<td width="15" bgcolor="E1EBC9" style="border-top: 1px solid #A1B17B;"></td>
<td width="175" bgcolor="E1EBC9" style="border-top: 1px solid #A1B17B;"><span class="MainText">Page <%=FormatNumber(intPage, Standard)%> of <% if not intPageCount = 0 then %><%=FormatNumber(intPageCount, Standard)%><% else %>1<% end if %></span></td>
<td width="55" bgcolor="E1EBC9" style="border-top: 1px solid #A1B17B;"></td>
<td width="110" bgcolor="E1EBC9" align="center" style="border-top: 1px solid #A1B17B;"></td>
<td width="55" bgcolor="E1EBC9" style="border-top: 1px solid #A1B17B;"><span class="MainText"><% if intPageCount < 1 then %><font color="#A1B17B">«</font> <font color="#A1B17B">»</font><% else %><% if intPage > 1 then %><a href="./listcat.asp?name=<%=kat("KatBesk")%>&page=<%= intPage-1 %>" class="MainLink01">«</a><% else %><font color="#A1B17B">«</font><% end if %> <% if not intPage = intPageCount then %><a href="./listcat.asp?name=<%=kat("KatBesk")%>&page=<%= intPage+1 %>" class="MainLink01">»</a><% else %><font color="#A1B17B">»</font><% end if %><% end if %></span></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<% end if %>
+-+-+-+-+-+-+
og den virker ikke med MySQL. Glem alt om "LIMIT".
Mvh
Mr.Meincke
