不知道你最终要达到什么目的,不过给你提供两种方案吧:你觉得哪种用起来方便顺手,就用哪一种吧:
第一种方案:取出数据库中date类型的数据后,进行if比较:
$sql="SELECT `字段名` FROM `vime` EHERE `id`='$id'";
$arr=mysql_query($sql);
$arr=mysql_fatch_array($arr);
$time = date('Y-m-d');
if($arr[字段名]<=$time){
echo '数据库中的日期小于服务器日期';
}
这种方案呢,本人一直在用,比较起来也是确实可用的。但是如果你想直接从数据库中取今天日期的数据的话,就可以用下面的这种方案,这种方案可是对资源节省方面大有好处哦:
第二种方案:
$sql="SELECT FROM `vime` EHERE `你存储日期的字段名` = now()";ASP本身不能实现该功能,但是可以用具有读写二进制文件功能的AdodbStream对象来间接实现
<%
'下面这段即可获得你要的那的宽和高
imgpath="images/photo/abcjpg"
set pp=new imgInfo
w = ppimgW(servermappath(imgpath))
h = ppimgH(servermappath(imgpath))
set pp=nothing
%>
<%
'这一段是所要用的类
Class imgInfo
dim aso
Private Sub Class_Initialize
set aso=CreateObject("AdodbStream")
asoMode=3
asoType=1
asoOpen
End Sub
Private Sub Class_Terminate
errclear
set aso=nothing
End Sub
Private Function Bin2Str(Bin)
Dim I, Str
For I=1 to LenB(Bin)
clow=MidB(Bin,I,1)
if ASCB(clow)<128 then
Str = Str & Chr(ASCB(clow))
else
I=I+1
if I <= LenB(Bin) then Str = Str & Chr(ASCW(MidB(Bin,I,1)&clow))
end if
Next
Bin2Str = Str
End Function
Private Function Num2Str(num,base,lens)
dim ret
ret = ""
while(num>=base)
ret = (num mod base) & ret
num = (num - num mod base)/base
wend
Num2Str = right(string(lens,"0") & num & ret,lens)
End Function
Private Function Str2Num(str,base)
dim ret
ret = 0
for i=1 to len(str)
ret = ret base + cint(mid(str,i,1))
next
Str2Num=ret
End Function
Private Function BinVal(bin)
dim ret
ret = 0
for i = lenb(bin) to 1 step -1
ret = ret 256 + ascb(midb(bin,i,1))
next
BinVal=ret
End Function
Private Function BinVal2(bin)
dim ret
ret = 0
for i = 1 to lenb(bin)
ret = ret 256 + ascb(midb(bin,i,1))
next
BinVal2=ret
End Function
Private Function getImageSize(filespec)
dim ret(3)
asoLoadFromFile(filespec)
bFlag=asoread(3)
select case hex(binVal(bFlag))
case "4E5089":
asoread(15)
ret(0)="PNG"
ret(1)=BinVal2(asoread(2))
asoread(2)
ret(2)=BinVal2(asoread(2))
case "464947":
asoread(3)
ret(0)="GIF"
ret(1)=BinVal(asoread(2))
ret(2)=BinVal(asoread(2))
case "535746":
asoread(5)
binData=asoRead(1)
sConv=Num2Str(ascb(binData),2 ,8)
nBits=Str2Num(left(sConv,5),2)
sConv=mid(sConv,6)
while(len(sConv)<nBits4)
binData=asoRead(1)
sConv=sConv&Num2Str(ascb(binData),2 ,8)
wend
ret(0)="SWF"
ret(1)=int(abs(Str2Num(mid(sConv,1nBits+1,nBits),2)-Str2Num(mid(sConv,0nBits+1,nBits),2))/20)
ret(2)=int(abs(Str2Num(mid(sConv,3nBits+1,nBits),2)-Str2Num(mid(sConv,2nBits+1,nBits),2))/20)
case "FFD8FF":
do
d p1=binVal(asoRead(1)): loop while p1=255 and not asoEOS
if p1>191 and p1<196 then exit do else asoread(binval2(asoRead(2))-2)
dp1=binVal(asoRead(1)):loop while p1<255 and not asoEOS
loop while true
asoRead(3)
ret(0)="JPG"
ret(2)=binval2(asoRead(2))
ret(1)=binval2(asoRead(2))
case else:
if left(Bin2Str(bFlag),2)="BM" then
asoRead(15)
ret(0)="BMP"
ret(1)=binval(asoRead(4))
ret(2)=binval(asoRead(4))
else
ret(0)=""
end if
end select
ret(3)="width=""" & ret(1) &""" height=""" & ret(2) &""""
getimagesize=ret
End Function
Public Function imgW(pic_path)
Set fso1 = serverCreateObject("ScriptingFileSystemObject")
If (fso1FileExists(pic_path)) Then
Set f1 = fso1GetFile(pic_path)
ext=fso1GetExtensionName(pic_path)
select case ext
case "gif","bmp","jpg","png":
arr=getImageSize(f1path)
imgW = arr(1)
end select
Set f1=nothing
else
imgW = 0
End if
Set fso1=nothing
End Function
Public Function imgH(pic_path)
Set fso1 = serverCreateObject("ScriptingFileSystemObject")
If (fso1FileExists(pic_path)) Then
Set f1 = fso1GetFile(pic_path)
ext=fso1GetExtensionName(pic_path)
select case ext
case "gif","bmp","jpg","png":
arr=getImageSize(f1path)
imgH = arr(2)
end select
Set f1=nothing
else
imgH = 0
End if
Set fso1=nothing
End Function
End Class
%>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)