Forum Moderators: open

Message Too Old, No Replies

Need some help

picture, listing, paging

         

Totte

10:30 pm on Mar 26, 2003 (gmt 0)

10+ Year Member



HI all.
need some little help from you.

Im listing all my pictures like this on my site

so if i have 40 picture catagorys, it list all on one site
(my design get ****ed then)

<table width="512" cellspacing="0" cellpadding="0" border="0">
<tr><td width="516">
<%sql="select * from galleripersoner where katid = "&request("galleriid")&""
set rs = conn.execute(sql)%>
<br><br>
<center>
<table width="516"><tr>
<%
i = 0
do until rs.eof%>

<% if (i mod 3) = 0 then
Response.Write("</tr><tr>")
end if%>
<td width="510">
<table cellspacing="0" cellpadding="0"><tr><td>

<%
SQL = "Select count(*) AS antal FROM galleribilder where katperid = "&rs("katperid")&""
Set RS3 = conn.Execute(SQL)

if rs3("antal") > 0 then

SQL = "Select * FROM galleribilder where katperid = "&rs("katperid")&""
RStemp = UBOUND(Conn.Execute(SQL).GetRows(),2)+1

Randomize
post = Int(RND*RStemp)
Set RS2 = Conn.Execute(SQL)
For s = 1 to post
RS2.MoveNext
Next
%>

<%
if rs2("width")=0 or rs2("height")=0 then
width=80
height=120
else
width=round((rs2("width")/3),0)
height=round((rs2("height")/3),0)
end if

%>
<table cellspacing="0" cellpadding="0" border="1" bordercolor="000000"><tr><td>

<a href="visa_bilder.asp?katperid=<%=rs("katperid")%>">
<img src="galleri/<%=RS2("bild")%>" WIDTH="<%=width%>" HEIGHT="<%=height%>" BORDER='0'></a></td></tr></table>
<%end if%>

<center>
[<a href="visa_bilder.asp?katperid=<%=rs("katperid")%>"><b><%=rs("namn")%></b></a>]<br>
<i><%=rs3("antal")%> bilder</i> </p>
</center>
</td></tr></table>

</td>

<%
i = i+1
rs.movenext
loop%>
</tr></table>

i would like it to list 9 (fits my design)

(3 colums and 3 rows )

Then it should be a link to "next page" and there it should list next 9

it should do that until there are no pictures to list

it should be good if it says your are on page 1 of? pages
and one text that says "back" if im at page 2

anyone knows how to change this in my code

i would be grateful if anyone could help me

takagi

2:10 pm on Mar 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Totte,

You want to generate the pictures in random order, but every picture only once. Next time the user visits the site, the order should be different, right?

I think you can solve this at the server side with Sessionid, so the server 'knows' what images have been displayed before. You first need an extra array with RStemp elements. Let's say RSTemp = 28. Fill this array with 1, 2, 3, 4, .. , 27 , 28. Now you randomly swap 2 elements. For example 2 and 5. So the array contains 1, 5, 3, 4, 2, 6, 7, .. , 27, 28. By placing this swap into a for-next that loops 2*RSTemp times, you end up with an array that has RSTemp elements from 1 to RSTemp in random order. But every number is only 1 time in the array. For page 1 you use the 1st - 9th element, for page 2 you use the 10th - 18th element etc.

You can also solve it at the client side by generating 1 page with layers or by changing the SRC of the 9 images being displayed.

Hope this helps. Success.