Buongiorno, la seguente parte di codice (credo), seleziona e visualizza i record con il campo data, popolato con la "data odierna" automaticamente, vorrei
disattivarla perchè:
es: se non sono presenti records inseriti con la data "odierna" non viene visualizzato niente (ovviamente), invece io vorrei visualizzare sempre l'ultimo
records, per non lasciare la pagina vuota nell'eventualità che non esistono record inseriti quotidianamente (per sportarsi fra i records c'è una specie di
calendario).
Qualcuno sa indicarmi cosa devo modificare?
La pagina è questa: http://www.mganga.com/news.asp
ciao ciao *Tempista*
<html>
<head>
<title>Mganga: tanzanian light</title>
<link href="/CSS/mganga.css" rel="stylesheet" type="text/css">
</head>
<body>
<div align="center">
<table width="700" border="0" cellpadding="0" style="border-collapse: collapse">
<tr>
<td width="300" align="left" valign="top" bgcolor="#000000"></td>
<td width="401" valign="top">
<table border="0" width="401" cellpadding="0" id="table1" style="border-collapse: collapse">
<tr>
<td width="401" height="15">[img]/images/angolo_alto_dx.gif[/img]</td>
</tr>
<tr>
<td width="401" height="700" align="left" valign="top" background="images/foglio_mezzo.gif">
<table border="0" width="100%" id="table2" cellspacing="12" cellpadding="10">
<tr>
<td align="left" valign="top">
<%
Function GetDaysInMonth(iMonth, iYear)
Dim dTemp
dTemp = DateAdd("d", -1, DateSerial(iYear, iMonth + 1, 1))
GetDaysInMonth = Day(dTemp)
End Function
Function GetWeekdayMonthStartsOn(dAnyDayInTheMonth)
Dim dTemp
dTemp = DateAdd("d", -(Day(dAnyDayInTheMonth) - 1), dAnyDayInTheMonth)
GetWeekdayMonthStartsOn = WeekDay(dTemp)
End Function
Function SubtractOneMonth(dDate)
SubtractOneMonth = DateAdd("m", -1, dDate)
End Function
Function AddOneMonth(dDate)
AddOneMonth = DateAdd("m", 1, dDate)
End Function
Dim dDate
Dim iDIM
Dim iDOW
Dim iCurrent
Dim iPosition
If IsDate(Request.QueryString("date")) Then
dDate = CDate(Request.QueryString("date"))
Else
If IsDate(Request.QueryString("day") & "/" & Request.QueryString("month") & "/" & Request.QueryString("year")) Then
dDate = CDate(Request.QueryString("day") & "/" & Request.QueryString("month") & "/" & Request.QueryString("year"))
Else
dDate = Date()
If Len(Request.QueryString("day")) <> 0 Or Len(Request.QueryString("month")) <> 0 Or Len(Request.QueryString("year")) <> 0 Or Len(Request.QueryString("date")) <> 0 Then
Response.Write "<font face='Verdana' size='1'><center>La data che hai selezionato risulta errata.
Il calendario è stato impostato alla data corrente.
"
End If
End If
End If
iDIM = GetDaysInMonth(Month(dDate), Year(dDate))
iDOW = GetWeekdayMonthStartsOn(dDate)
%>
<h3>NEWS</h3>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 width="251">
<TR>
<TD ALIGN="center" width="76"> <font face="Verdana" size="1"><span lang="it">Giorno</span></font></TD>
<TD ALIGN="center" width="89"> <font face="Verdana" size="1"><span lang="it">Mese</span></font></TD>
<TD ALIGN="center" width="86"> <font face="Verdana" size="1"><span lang="it">Anno</span></font></TD>
</TR>
<TR> <TD ALIGN="center" width="76">
<FORM ACTION="news.asp" METHOD=GET>
<SELECT NAME="day" style="font-family: Verdana; font-size: 8 pt; color: #000000; border: 1px solid #000080; background-color: #FFFFFF">
<OPTION VALUE=1>1</OPTION>
<OPTION VALUE=2>2</OPTION>
<OPTION VALUE=3>3</OPTION>
<OPTION VALUE=4>4</OPTION>
<OPTION VALUE=5>5</OPTION>
<OPTION VALUE=6>6</OPTION>
<OPTION VALUE=7>7</OPTION>
<OPTION VALUE=8>8</OPTION>
<OPTION VALUE=9>9</OPTION>
<OPTION VALUE=10>10</OPTION>
<OPTION VALUE=11>11</OPTION>
<OPTION VALUE=12>12</OPTION>
<OPTION VALUE=13>13</OPTION>
<OPTION VALUE=14>14</OPTION>
<OPTION VALUE=15>15</OPTION>
<OPTION VALUE=16>16</OPTION>
<OPTION VALUE=17>17</OPTION>
<OPTION VALUE=18>18</OPTION>
<OPTION VALUE=19>19</OPTION>
<OPTION VALUE=20>20</OPTION>
<OPTION VALUE=21>21</OPTION>
<OPTION VALUE=22>22</OPTION>
<OPTION VALUE=23>23</OPTION>
<OPTION VALUE=24>24</OPTION>
<OPTION VALUE=25>25</OPTION>
<OPTION VALUE=26>26</OPTION>
<OPTION VALUE=27>27</OPTION>
<OPTION VALUE=28>28</OPTION>
<OPTION VALUE=29>29</OPTION>
<OPTION VALUE=30>30</OPTION>
<OPTION VALUE=31>31</OPTION>
</SELECT><TD ALIGN="center" width="89">
<SELECT NAME="month">
<OPTION VALUE=1>Gennaio</OPTION>
<OPTION VALUE=2>Febbraio</OPTION>
<OPTION VALUE=3>Marzo</OPTION>
<OPTION VALUE=4>Aprile</OPTION>
<OPTION VALUE=5>Maggio</OPTION>
<OPTION VALUE=6>Giugno</OPTION>
<OPTION VALUE=7>Luglio</OPTION>
<OPTION VALUE=8>Agosto</OPTION>
<OPTION VALUE=9>Settembre</OPTION>
<OPTION VALUE=10>Ottobre</OPTION>
<OPTION VALUE=11>Novembre</OPTION>
<OPTION VALUE=12>Dicembre</OPTION>
</SELECT>
<TD ALIGN="center" width="86"><SELECT NAME="year">
<OPTION VALUE=2004>2004</OPTION>
<OPTION VALUE=2005>2005</OPTION>
<OPTION VALUE=2006>2006</OPTION>
<OPTION VALUE=2007>2007</OPTION>
<OPTION VALUE=2008>2008</OPTION>
<OPTION VALUE=2009>2009</OPTION>
<OPTION VALUE=2010>2010</OPTION>
</SELECT></TD>
<TR>
<TD ALIGN="center" colspan="3" width="217">
<INPUT TYPE="submit" VALUE="Cerca">
</FORM>
</TR>
</TABLE>
<%
id = Request.QueryString( "id" ).item
RicercaData=ddate
RicercaData2="#" & month(RicercaData) & "/" & day(RicercaData) & "/" & year(RicercaData) & "#"
Response.Write(data2)
Set Conn=Server.CreateObject("ADODB.Connection")
Conn.Open "PROVIDER=MSDASQL;" & _
"DRIVER={Microsoft Access Driver (*.mdb)}; " & _
"DBQ=" & server.mappath("/mdb-database/database.mdb")
sql="select TOP 2 * from NEWS where data ="& RicercaData2 &" ;"
set rs=Conn.Execute(sql)
'strdata=request.querystring("DATA")
'Rs.filter=" DATA = 'strdata' "
%>
<% While not rs.EOF %>
<h3><%=rs.Fields("data")%></h3>
<h2><%=rs.Fields("titolo")%></h2>
<p align="justify" style="text-align: justify">
<%=rs.Fields("descrizione")%></p>
/" target="_blank"><%=rs.Fields("link")%>
<%
rs.MoveNext
Wend
%>
<%
Rs.Close
set Rs = Nothing
Conn.Close
set Conn = Nothing
%>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="401" height="11">[img]/images/angolo_basso_dx.gif[/img]</td>
</tr>
</table>
</div>
</body>
</html>

Rispondi quotando