日期:2014-05-17 浏览次数:20917 次
Dim rslou,nm nm = Easp.R("n","1:10") Set rslou = Easp.db.GetRecordBySQL("SELECT TOP "&nm&" chrloupan, shouloutel, avgprice, filepath, chraddress FROM mh163k_house_loupan WHERE iskill = 1 ORDER BY loupanid DESC") While Not rslou.eof a="[" while not rslou.eof and not rslou.bof b="{""id"":"&rslou("shouloutel")&",""title"":"&rslou("shouloutel")&"}," rslou.movenext() a=a&b wend a=a&"]" response.write(a) Wend Easp.db.C(rslou)
'不要去判断,影响效率,直接去掉最后一个 b=left(b,len(b)-1) '或 b=mid(b,1,len(b)-1) a=a&b
------解决方案--------------------
strComma = "" while not rslou.eof and not rslou.bof b="{""id"":"&rslou("shouloutel")&",""title"":"&rslou("shouloutel")&"}" rslou.movenext() a=a & strComma & b strComma = "," wend