Avatar billede tusseballer Nybegynder
16. november 2003 - 15:02 Der er 1 løsning

Vil ikke vise nyheden

jeg ved ikke hvad der er galt men den vil gerne vise overskriften på nyheden, men ikke hele nyheden. Nogen der kan hjælpe..



<%
'###################################################
'# Setup
'###################################################
' // Name of Template File.
NewsTemplatePath="./nyheder.asp"

' // Virtuel Path. (Where the files are located)
NewsFilePath="/"

'// Database connection string
FinNewsConstr = "Provider=MICROSOFT.JET.OLEDB.4.0; Data Source="&server.mappath(NewsFilePath&"admin/031019461711772657.mdb")

' // Debug Mode. (Show Error Msg if any Errors)
NewsDebugMode=false

' // Date format. Set to 1033 if using American date format
Session.LCID = 3081

' ####################
' ## Look and feel  ##
' ####################
' // newsBgImage : Used for background color,thin lines and graph bars.
newsBgImage = "215D84.gif"

' // newsFont : Used for text
newsFont = "<font face=""Verdana"" color=""#000000"" size=""2"">"

' // newsFont : Used for text in Box
newsFontBox = "<font face=""Verdana"" color=""#000000"" size=""1"">"

' // newsHeading : Heading for the Box.
' // Use a image to make it look nice, otherwise uncomment the other line and change the text and/or font
newsHeading = "<img src="""&NewsFilePath&"images/news_text.gif"">"
'newsHeading = "<u><b><font color=""#FFFFFF"" face=""Verdana"" size=""2"">Latest News</font></b></u>"

'Number of max news items to show in box
newsMaxNo=3

'#####################################################################
'## Text used in script. Change this to your own words/Language    ##
'#####################################################################
'Text for "more"
newsTxtMore="Hele nyheden"
'Text for "News Archive"
newsTxtNewsArchive="Alle nyheder"

'###################################################
'# Start
'###################################################
' // Setup DBStuff
dim FinNewsDB,FinNewsRS
set FinNewsDB=server.createobject("ADODB.Connection")
set FinNewsRS=server.createobject("ADODB.Recordset")

' // Get mode we are in
dim sModeFin

sModeFin = LCase(request("FinNewsMode"))
SELECT CASE sModeFin
    CASE "archive"
        showArchive()
    CASE "viewdetails"
        showDetails()
    CASE else
        showNewsBox()
END SELECT

' // Cleanup
set FinNewsRS=nothing
set FinNewsDB=nothing

'############################################
'# showNewsBox()
'# Get the lastest "newsMaxNo" news items and show box
'############################################
function showNewsBox()
' // Get the data
FinNewsOpenDB()
FinNewsRS.open "select top "&newsMaxNo&" * from nyhed ORDER BY NewsDateTime DESC",FinNewsDB,1,1
if not (FinNewsRS.bof and FinNewsRS.eof) then
    ' // Write out table Header
    %>
<table border="0" cellspacing="0" width="140">
<tr>
    <td width="100%" background="<%=newsFilePath%>images/<%=newsBgImage%>">
    <table border="0" cellspacing="0" width="140" background="<%=newsFilePath%>images/ffffff.gif">
    <tr>
        <td colspan="2" background="<%=newsFilePath%>images/<%=newsBgImage%>" width="140" align="center"><img src="<%=NewsFilePath%>images/spacer.gif" height=3 width=3><br><%=newsHeading%><br><img src="<%=NewsFilePath%>images/spacer.gif" height=3 width=3></td>
    </tr>
    <tr>
        <td width="140" valign="top" align="center" colspan="2"><img src="<%=NewsFilePath%>images/spacer.gif" height=4 width=1></td>
    </tr>
    <%
    ' // Write out each news item
    while not FinNewsRS.eof
        %>
        <tr>
            <td width="10" valign="top" align="right"><%=newsFontBox%>·</font></td>
            <td width="130" valign="top" align="left"><%=newsFontBox%>(<%=myDateFormat(FinNewsRS("NewsDateTime"))%>)<br><%=FinNewsRS("Heading")%>.&nbsp;<a href="<%=NewsTemplatePath%>?FinNewsMode=ViewDetails&FinNewsID=<%=FinNewsRS("ID")%>"><%=newsTxtMore%></a></font><br><img src="<%=NewsFilePath%>images/spacer.gif" height=4 width=1></td>
        </tr>
        <%
        FinNewsRS.movenext
    wend

    ' // Write out table Footer
    %>
    <tr>
        <td width="140" valign="top" align="center" colspan="2"><img src="<%=NewsFilePath%>images/<%=newsBgImage%>" height=1 width=95%></td>
    </tr>
    <tr>
        <td width="140" valign="top" align="center" colspan="2"><%=newsFontBox%><a href="<%=NewsTemplatePath%>?FinNewsMode=Archive"><%=newsTxtNewsArchive%></a></font></td>
    </tr>
    </table>
    </td>
</tr>
</table>
    <%
FinNewsRS.close
FinNewsDB.close

end if
end function

'############################################
'# showArchive()
'# Show all the news in the Archive (Short form)
'############################################
function showArchive()
' // Get the data
FinNewsOpenDB()
FinNewsRS.open "select * from nyhed ORDER BY NewsDateTime DESC",FinNewsDB,1,1
if not (FinNewsRS.bof and FinNewsRS.eof) then
    ' // Write out table Header
    %>
    <table border="0" cellspacing="0" width="100%">
    <tr><td width="140" valign="top" align="Left" colspan="2"><%=newsFont%><font size="2"><u><b><%=newsTxtNewsArchive%></b></u></font></font></td></tr>
    <tr><td width="140" valign="top" align="center" colspan="2"><img src="<%=NewsFilePath%>images/spacer.gif" height=4 width=1></td></tr>
    <%
    ' // Write out each news item
    while not FinNewsRS.eof
        %>
        <tr>
            <td width="10" valign="top" align="right"><%=newsFont%>·</font></td>
            <td width="100%" valign="top" align="left"><%=newsFont%>(<%=myDateFormat(FinNewsRS("NewsDateTime"))%>)<br><%=FinNewsRS("Heading")%>.&nbsp;<a href="<%=NewsTemplatePath%>?FinNewsMode=ViewDetails&FinNewsID=<%=FinNewsRS("ID")%>"><%=newsTxtMore%></a></font><br><img src="<%=NewsFilePath%>images/spacer.gif" height=4 width=1></td>
        </tr>
        <%
        FinNewsRS.movenext
    wend

    ' // Write out table Footer
    %>
    </table>
    <%
FinNewsRS.close
FinNewsDB.close
end if
end function

'############################################
'# showDetails()
'# Show the selected news item using the template
'############################################
function showDetails()

dim FinNewsID
FinNewsID=request("FinNewsID")
if FinNewsID="" then
    Response.write("Kunne ikke finde nyheden")
end if

' // Get the data
FinNewsOpenDB()
FinNewsRS.open "select * from nyhed where ID="&FinNewsID,FinNewsDB,1,1
if not (FinNewsRS.bof and FinNewsRS.eof) then
    ' // Write out table Header
    %>
    <table border="0" cellspacing="0" width="100%">
    <tr>
        <td width="10" valign="top" align="right">&nbsp;</td>
        <td width="100%" valign="top" align="left"><center><%=newsFont%><font size="2"><b><%=FinNewsRS("Heading")%></b></font><br>
        <%=newsFont%>(<%=myDateFormat(FinNewsRS("NewsDateTime"))%>)</center><br>
        <%=FinNewsRS("FullText")%></font><br><img src="<%=NewsFilePath%>images/spacer.gif" height=4 width=1></td>
    <tr>
        <td width="100%" valign="top" align="center" colspan="2"><%=newsFont%><a href="<%=NewsTemplatePath%>?FinNewsMode=Archive"><%=newsTxtNewsArchive%></a></font><br><br></td>
    </tr>
    </tr>
    </table>
    <%
FinNewsRS.close
FinNewsDB.close
end if
end function

'############################################
'# FinNewsOpenDB()
'# Open database, show error if any problems
'############################################
sub FinNewsOpenDB()
On ERROR Resume next
FinNewsDB.open FinNewsConstr, "",""
if Err.number<>0 then
    Response.write("Nyheder kan ikke hentes lige nu, prøv igen")
    Response.end
end if
ON ERROR GOTO 0
end sub

'#############################################
'# myDateFormat(myDate)
'# Make the date look nice. DD/MM/YYYY if euro
'#############################################
function myDateFormat(myDate)
myDate=FormatDateTime(myDate,2)
tmpArray = split( myDate, "/" )
if len(tmpArray(0))<2 then tmpArray(0)= "0"&tmpArray(0)
if len(tmpArray(1))<2 then tmpArray(1)= "0"&tmpArray(1)
if len(tmpArray(2))<4 then tmpArray(2)= "20"&tmpArray(2)
myDateFormat = join(tmpArray,"/")
end function
%>
Avatar billede tusseballer Nybegynder
17. november 2003 - 02:04 #1
har fået det til at virke. lukker igen
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester