1樓:網友
分兩步就行了,先找出不同的前5個答案表中的id,再根據這個id問題表中找問題。如下:
1.找出不同的前5個問題:mydate為答案表中的時間欄位。
sql="select top 5 distinct idfrom 答案表名 order by mydate desc"
set rs1=
2.得到id後,去問題表中找,其中question為問題表中的問題欄位。
sql="select question from 問題表名。
where id='"rs1("id")&set rs2=
得到了想要的結果。rs2("question")就是所要的5個問題。
2樓:北福
select top5 * from 問題表 order by 時間 desc
取出問題的id,再通過id取得答案表裡的答案。
select * form where id=id大致思路是這樣!
asp怎麼從指定的值內不重複取出隨機值。
3樓:網友
思路很簡單,不考慮排序的話,可以理解成將數字隨機排序,然後列印出4個值。
1. 不考慮原來排序順序取值,相當於排列組合中的c12/4
dim t,l,i,tmp
t=split("1,2,3,4,5,6,a,b,c,d,e,f",",")
隨機排序。l=ubound(t)
randomize
for i=0 to l-1
b=int(rnd()*leng)
tmp=t(b)
t(b)=t(i)
t(i)=tmp
nextfor i=0 to 3
t(i)&"
next>如果考慮排序問題,就用下面方法,隨機抽取。
2.考慮原來排序順序取值,相當於排列組合中的p12/4
dim arr
arr = array("1","2","3","4","5","6","a","b","c","d","e","f")
arr)&"
function getrandomarray(m, arr)
dim intmax,intleft
intleft = m
intmax = ubound(arr)
getrandomarray=""
count = 0
do while intleft > 0
dim tvalue,tindexarray
dim trnd
randomize
count =count + 1
trnd = int(intmax * rnd)
tvalue = ""
intleft )
if instr( 1,getrandomarray,tvalue,1)>0 then
elsegetrandomarray = getrandomarray & tvalue
intleft = intleft-1
end if
if count > 20 then exit do
loopend function
4樓:網友
tonylinzhen,變數t就是這個功能哈<%
dim myarray(12)
myarray(0)="1"
myarray(1)="2"
myarray(2)="3"
myarray(3)="4"
myarray(4)="5"
myarray(5)="6"
myarray(6)="7"
myarray(7)="8"
myarray(8)="9"
myarray(9)="a"
myarray(10)="b"
myarray(11)="c"
myarray(12)="d" '只定義了12個元素,這個是第13個了。
dim mynum(4) '讀出的4個值在這個陣列裡for i=0 to 3
獲取隨機數。
randomize()
n=int(11*rnd(now())
判斷是否重複。
t=0for j=0 to i
if myarray(n) = mynum(j) thent=1end if
nextif t=0 then
mynum(i) = myarray(n)else
i = i-1
end ifnext
5樓:網友
樓上方法可以,但處理的數很多時有些不足。將陣列的各個元素設定標誌,初始值為false,取到該元素時標記true。
asp取隨即不重複數的問題
6樓:網友
mac=split("a,b,c,d,e,f,g",",")for i=1 to ubound(mac)-1nextfunction getrnd(bound)dim rannum
randomize()
rannum=int(bound*rnd)>0 then rannum = getrnd(bound)getrnd = rannum
end function
你這樣寫看看是不是就對了。
你的那個getrnd函式也沒錯,在vb中0和null就是假值。
所以不用》0也可以。
豪情幾許 23:33:21
跟我的**有什麼區別?
asp重複值的問題
7樓:網友
先根據ip的值獲取表裡面相同值的總數,如果大於等於3次就為真這樣就可用了,你獲得的num的值就是所有和ip相同的值的總數引用時用 rs("num"),前提是你的記錄集是rs
8樓:勇敢的風
if choip(getip())thencall alert ("你的ip:"&getip()&"已經用過3次了")
end if
第一,要大於等於3才行。
第二,choip已經是真或者假了,就不需要在進行比較了。
asp 要取所有值而不是選定值
9樓:網友
"以選選項:" "aa")
所有選項:" "gg")
分開來: checks=split("gg"),for i = 0 to ubound(checks)
在asp中怎麼取元素值
10樓:網友
dim i,x
for i = 0 to ubound(a)x = a(i)
.遍歷陣列所仔檔有元素搭薯,想幹啥就知戚者幹啥吧。
next
asp取不重複的資料時增加條件的問題
11樓:隨性亻
那你這樣做,先擷取一下,再用distinct取出重複的值就行了。
asp取不重複的資料時,增加條件的問題
12樓:網友
distinct 再用 * 就失去了,去重的目的(distinct 失效)。
也就是說 distinct ,只能顯示這個 distinct的列。
asp裡面textbox取不到值
13樓:定復
你用的是get還是post?
我路過看看而已的。
14樓:百新小鋪
可以用post取值。
string uname = "uname"];
這樣應該可以吧。
asp兩個表取共同值,asp 取兩個表裡的值
用巢狀迴圈吧,掌握起來簡單一點。第一級迴圈 大類。sql select from wenti set rs sql,conn,, while not 第二級迴圈 小類 blass的id 等於 wenti 的 bclassid set rs sql,conn,, while not rs bclass...
asp取資料庫內容
改成 sql1 select from notice where id order by id desc rs.open sql1,conn,1,1if not rs.eof and not rs.bof thenrs.pagesize 10 rs.absolutepage 1 for i 1 to...
asp的程式設計問題
false,預設為false,當設定為true時,伺服器端的資料會先輸出到緩衝區,然後再從緩衝區輸出至客戶端,如果取預設狀態下的false,則伺服器端的資料會直接輸出到客戶端瀏覽器。格式 response.buffer true 示例 response.buffer true if request....