Click to See Complete Forum and Search --> : ASP randomise Script


freshtea
08-15-2006, 08:44 AM
Hi

I need to create a randomise script on the following page and only display one at at a time

If anyone can do it I will throw a few quid your way :)


==========================
<%

'::::::::::::::::::::::::::::::::::::::::


':::: recommended DATABASE SCHEMA for this page

' Content:
' ContentID: int identity|int: 4
' user_id: int identity|int: 4
' ContentTypeID: int identity|int: 4
' CatID: int identity|int: 4
' Title: text|varchar: 100
' Author: text|varchar: 50
' FileName: text|varchar: 100
' EmbedFile: byte: 1
' RelatedURL: text|varchar: 70
' DownloadURL: text|varchar: 80
' DateAdded: datetime: 8
' DateLastMod: datetime: 8
' ShortDesc: longtext|memo: 536870910
' LongDesc: longtext|memo: 536870910
' Display: byte: 1
' AccessLevel: smallint: 2
' RefList: text|varchar: 255
' EMail: text|varchar: 50
' Expire: datetime: 8
' Priority: int identity|int: 4
' Impressions: int identity|int: 4
' ClickThrus: int identity|int: 4
' Downloads: int identity|int: 4
' AvgRating: decimal: 19
' Ratings: int identity|int: 4
' Feature: byte: 1
' UtilValue: text|varchar: 30
' UtilFlag: byte: 1
' Thumbnail: text|varchar: 50
' Image1: text|varchar: 50
' Image2: text|varchar: 50
' PrevContentId: int identity|int: 4
' NextContentId: int identity|int: 4
' RelatedTopicId: int identity|int: 4
' ParentContentId: int identity|int: 4
' DateAlert: datetime: 8
' Status: smallint: 2
' CreatedBy: int identity|int: 4


' Cats:
' CatID: int identity|int: 4
' CatTypeId: int identity|int: 4
' Cat: text|varchar: 50
' ParentId: int identity|int: 4
' RelatedId: int identity|int: 4
' Description: longtext|memo: 536870910
' DisplayOrder: int identity|int: 4
' Image1: text|varchar: 100
' DefaultContentId: int identity|int: 4
' MenuLink: text|varchar: 100
' MenuImage: text|varchar: 80


' Users:
' user_id: int identity|int: 4
' user_type_id: smallint: 2
' group_id: int identity|int: 4
' user_name: text|varchar: 50
' f_name: text|varchar: 50
' l_name: text|varchar: 70
' email: text|varchar: 60
' password: text|varchar: 50
' addr1: text|varchar: 100
' addr2: text|varchar: 50
' city: text|varchar: 50
' state: text|varchar: 50
' postalcode: text|varchar: 50
' country: text|varchar: 50
' phone: text|varchar: 40
' fax: text|varchar: 40
' notes: longtext|memo: 536870910
' selfemp: byte: 1
' dtinserted: datetime: 8
' dtmodified: datetime: 8
' dtlast: datetime: 8
' accesslevel: int identity|int: 4
' mailing_list: byte: 1
' util_val: int identity|int: 4
' util_flag: byte: 1
' account_no: text|varchar: 40
' homepage_url: text|varchar: 70
' signature: text|varchar: 255
' image: text|varchar: 30
' refered_by: text|varchar: 30
' confirmed: byte: 1
' last_ip: text|varchar: 30


dim general_content_sql

sub request_general_content
Author = request("Author")
LongDesc = request("LongDesc")
Thumbnail = request("Thumbnail")
NextContentId = request("NextContentId")
Display = request("Display")
DateAdded = request("DateAdded")
Cat = request("Cat")
Feature = request("Feature")
ContentID = request("ContentID")
user_id = request("user_id")
Display = request("Display")
ContentTypeID = request("ContentTypeID")
CatID = request("CatID")
Title = request("Title")
User_name = request("User_name")
ShortDesc = request("ShortDesc")
end sub

sub validate_general_content
''' request and validate data entered from this form
Author = trim(request("Author"))
LongDesc = trim(request("LongDesc"))
Thumbnail = trim(request("Thumbnail"))
NextContentId = trim(request("NextContentId"))
Display = trim(request("Display"))
DateAdded = trim(request("DateAdded"))
Cat = trim(request("Cat"))
Feature = trim(request("Feature"))
ContentID = trim(request("ContentID"))
user_id = trim(request("user_id"))
Display = trim(request("Display"))
ContentTypeID = trim(request("ContentTypeID"))
CatID = trim(request("CatID"))
Title = trim(request("Title"))
User_name = trim(request("User_name"))
ShortDesc = trim(request("ShortDesc"))
end sub


sub db_select_general_content
general_content_sql = "SELECT " & _
"Content.ContentTypeID, " & _
"Content.user_id, " & _
"Cats.CatID, " & _
"Users.user_name, " & _
"Content.Title, " & _
"Content.Author, " & _
"Content.LongDesc, " & _
"Content.Thumbnail, " & _
"Content.NextContentId, " & _
"Content.Display, " & _
"Content.DateAdded, " & _
"Content.ShortDesc, " & _
"Content.Display, " & _
"Content.Impressions, " & _
"Content.ClickThrus, " & _
"Content.Feature, " & _
"Cats.Cat, " & _
"Content.ContentID FROM ((Users RIGHT JOIN Content ON Users.user_id = Content.user_id)" & _
" RIGHT JOIN Cats ON Content.CatID = Cats.CatID)" & _
" WHERE (Expire > " & to_sql(now,"absdate") & " or Expire is NULL) AND Display=1 AND ContentTypeID = 1 " & _
" ORDER BY Priority, DateAdded DESC"
end sub


':: request action
action = lcase(request("action"))

':: handle the action
select case action

case "select_general_content"
' select the requested key record from database
db_select_general_content


end select

':: handle the default case(s) (ignores value of action parameter)
db_select_general_content
ListFields=application("default_listfields")
if isNull(ListFields) then ListFields="|Title|,|ShortDesc|,|Thumbnail|,|DateAdded|"
%>




<% ctr=0 %>
<%

page_no = request("page_no")
if page_no = "" then page_no = 1

if general_content_sql <> "" then
cmd.CommandText = general_content_sql
rs.Filter = ""
rs.CursorLocation = 3
rs.CacheSize = 5
rs.Open cmd
if not rs.EOF then
rs.MoveFirst
num_recs = rs.RecordCount
results = true
else
results = false
rs.Close
end if
else
results = false
end if
rec_count = 0

%>

<%

if results = true then



%>




<table width="400" height="202" cellpadding="0" cellspacing="0">
<tr>
<td width="15" height="15"><img src="/styles/spinfm/images/left_top_corner_blue.gif"></td>
<td width="389" background="/styles/spinfm/images/top_bar_blue.gif"></td>
<td width="16"><img src="/styles/spinfm/images/right_top_corner_blue.gif"></td>
</tr>
<tr>
<td height="40" background="/styles/spinfm/images/left_bar_blue.gif" bgcolor="#419BC0"></td>
<td bgcolor="#219DBF"><img src="../images/content/home/title_home_promotions.gif" width="400" height="40">
<td background="/styles/spinfm/images/right_bar_blue.gif" bgcolor="#239CBE"></td>
</tr>
<tr>
<td height="130" background="/styles/spinfm/images/left_bar_blue.gif" bgcolor="#419BC0"></td>
<td bgcolor="#219DBF">
<table width="215" cols="2">
<%

do while not rs.EOF

':: read db record
on error resume next
Author = rs("Author")
LongDesc = rs("LongDesc")
Thumbnail = rs("Thumbnail")
NextContentId = rs("NextContentId")
Display = rs("Display")
DateAdded = rs("DateAdded")
Cat = rs("Cat")
Feature = rs("Feature")
ContentID = rs("ContentID")
user_id = rs("user_id")
Display = rs("Display")
ContentTypeID = rs("ContentTypeID")
CatID = rs("CatID")
Title = rs("Title")
User_name = rs("User_name")
ShortDesc = rs("ShortDesc")
on error goto 0

%>

<tr><td>
<FONT class='HomeContentHeadFont'><%=Title%></font>
<A href='<% if Display then %>content.asp?ContentId=<%=ContentId%><% elseif NextContentId>0 then %>content.asp?ContentId=<% =NextContentId %><% end if %>'><img class='ThumbnaillistHomepage' src='<%=Thumbnail%>'></A>
</td>

</tr>

<%

rs.MoveNext
rec_count = rec_count + 1
loop
rs.Close

%>
</table>
<td background="/styles/spinfm/images/right_bar_blue.gif" bgcolor="#239CBE"></td>
</tr>
<tr>
<td height="15"><img src="/styles/spinfm/images/left_bottom_corner_blue.gif"></td>
<td height="15" background="/styles/spinfm/images/bottom_bar_blue.gif" bgcolor="#219DBF"></td>
<td height="15"><img src="/styles/spinfm/images/right_bottom_corner_blue.gif"></td>
</tr>
</table>



<%

else

%>



<%

end if

%>