Originariamente inviato da imente
killer
se leggi in cima c'è scritto
indi vuole 1 solo record
esatto quindi quello da me scritto è giusto... :S
è una cosa che sonosco da quando scrivo codice...
se non fai un ciclo, e usi quella qry lui restituisce 1 solo valore....
quindi è inutile fare top 1 o max(id)
se invece fai un ciclo, è stupido... cos'è fai un ciclo con top 1 !?!?!?
tanto per dimostrare che ho ragione...
http://test.coretech.it/sito/news_test.asp
come vedete tira fuora 1 sola news... e questo è il codice della pagina:
codice:
<%
dim rs
set rs=server.CreateObject("ADODB.RecordSet")
dim sql
id=Request.QueryString("id")
sql="select * from news "
rs.Open sql, cn,1,3
%>
<table width="100%" border="0" cellpadding="0" height="47">
<tr>
<td width="2%" valign="top" height="50"></td>
<td width="5%" valign="top" height="50">','News','scrollbars=yes,resizable=yes,width=620,height=500')">[img]images/ico_file.gif[/img]</td>
<td colspan="2" valign="top" width="93%" height="50">
<p class="titolonews"><span class="DATA_NEWS"><%=rs("data")%></span><font face="Arial" size="2"><span class="testo11">
-</span> <font color="#4C85BC">
<%
if Request.Cookies("coretech") = "" then
Response.write rs("titolo")
else
%>"><%=rs("titolo")%>
<%end if%>
</font>
<span class="testo11">
<%'url e link
stringa = rs("news")
stringa=replace(stringa,chr(13),"
")
stringa=replace(stringa,vbcrlf," ")
stringa=replace(stringa,vblf," ")
arrstringa = split(stringa," ")
for each word in arrstringa
if instr(word,"http://www.") then
response.write "" & word & " "
elseif instr(word,"www.") then
response.write "" & word & " "
elseif instr(word,"http://") then
response.write "" & word & " "
elseif instr(word,"@") then
response.write "" & word & " "
else
response.write word & " "
end if
next
%>
</span></font></p>
</td>
</tr>
</table>
<%
rs.Close
set rs=nothing
cn.close
set cn=nothing
Response.write SQL
Response.end
%>
Ovviamente ha preso la prima news che ha trovato, basta fare order by id desc...
e il gioco è fatto...