请问各位高手asp的一个问题,我刚学的!!谢谢

请问各位高手asp的一个问题,我刚学的!!谢谢,第1张

方法有三种

1:声明一个全局变量

就是在函数外部声明,给变量赋值,然后在函数里直接引用就是了

2:可以在调用函数的时候把参数传递进去

函数这样写

Function Pho(某变量)

......

End Function

调用的时候这样写 Pho(要传递进去的值)

3:在函数内部读取数据库

给你写了个最简单的,你用记事本复制下来,保存为.htm格式测试下

<SCRIPT language = "JavaScript">

var onecount1

onecount1=0

subcat = new Array()

subcat[0] = new Array("手机","pho","63")//注意“手机”后面这个"pho" 那是代表你从表单中提取的value

subcat[1] = new Array("电话传真机","pho","64")//同上

subcat[2] = new Array("sim卡","card","66")//注意“sim卡”后面这个"card" 那是代表你从表单中提取的value

subcat[3] = new Array("IC/IP卡","card","67")//同上

onecount1=4

function changelocation(locationid)

{

document.myform.diqu2.length = 0

var locationid=locationid

var i

for (i=0i <onecount1i++)

{

if (subcat[i][1] == locationid)

{

document.myform.diqu2.options[document.myform.diqu2.length] = new Option(subcat[i][0], subcat[i][2])

}

}

}

</SCRIPT>

<form action="" name="myform" method="POST">

<SELECT name="diqu1" onChange="changelocation(document.myform.diqu1.options[document.myform.diqu1.selectedIndex].value)" size="1">

<OPTION selected value="0">信息类别</OPTION>

<OPTION value="pho">电话类型</OPTION>

<OPTION value="card">电话卡</OPTION>>

</SELECT><SELECT name="diqu2">

<OPTION selected value="0">二级分类</OPTION>

</SELECT>

</form>

这是以前写的个读取目录下所有图片的例子,你可以参考

<?php

include_once('./php/cfg/config.inc.php')//配置文件

include_once("./php/inc/dbmysql.inc.php")//一个php数据库类

include_once("./php/inc/functions.php")

ob_start()

date_default_timezone_set('Asia/Shanghai')

//$stdin = fopen("php://input", "r")

//db connet

$dbInst = new $dbconfig['type']()

$dbInst ->dbConnect($dbconfig['off_man_spec'])//DB CON

//<-- con end

$log_name = "log/readtheme_error.txt"

$log_gif = "log/readtheme_gif.txt"

$to_now=date('Y-m-d H:i:s', time())

$gif_array =array()

function ls($dir, $mask /*.php$|.txt$*/)

{

static $i = 0

$files = Array()

$d = opendir($dir)

while ($file = readdir($d))

{

if ($file == '.' || $file == '..' || eregi($mask, $file) ) continue

if (is_dir($dir.'/'.$file))

{

$files += ls($dir.'/'.$file, $mask)

continue

}

$files[$i++] = $dir.'/'.$file

//$files[$i++] =$file

//echo $dir.'<br/>'

insert_sql($dir,$file,$i)

}

return $files

}

function insert_sql($di,$fi,$k){

global $dbInst,$to_now,$log_name,$gif_array,$log_gif

//得到唯一标示:gif与对应主题包

$strs_f =explode('-',$fi,4)

$upload_file_attr =$strs_f[0].'-'.$strs_f[1].'-'.$strs_f[2]

$file_z = explode('.',$fi)

if('gif'==$file_z[1]){

$gif_array[$k] =$fi

log_add($log_gif,$fi."\r\n")

return

}

$dir_z = explode('/',$di)

$belongtype = $dir_z[2]

$symbian_version =strtolower($dir_z[1])

$showname =substr ($dir_z[3],3)

$up_filename =$fi

$sql = "INSERT INTO `pho_upload_theme_test` (`upload_filename` ,`belongtype` ,`symbian_version`,`showname`,`upload_time`,`upload_file_attr` )VALUES ('$up_filename', '$belongtype', '$symbian_version','$showname','$to_now','$upload_file_attr')"

$res = $dbInst ->query ($sql)

if(!$res)log_add($log_name,$sql."\r\n")

//$dir_z = explode('.',$di)

//echo $file_z[1].'<br/>'

}

function gif_insert($arr){

global $dbInst,$to_now,$log_name

foreach($arr as $val){

$resolution =''

$strs_v =explode('.',$val)

$strs_f =explode('-',$strs_v[0])

$key = $strs_f[0].'-'.$strs_f[1].'-'.$strs_f[2]

$resolution =$strs_f[3].'-'.$strs_f[4]

$sql = "INSERT INTO `pho_upload_theme_attr` (`filename` ,`upid` ,`resolution`,`upload_time` )VALUES ('$val', (select IF(ISNULL(upid),1,upid) FROM pho_upload_theme_test where upload_file_attr='$key'), '$resolution','$to_now')"

$res = $dbInst ->query ($sql)

//return $res

if(!$res)log_add($log_name,$sql."\r\n")

}

}

$f = ls('D:\\theme', ".db$|.php$" /*no spaces*/)

//写入gif

$resl =gif_insert($gif_array)

echo '成功'

$dbInst ->close()

//print_r($f)

?>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/9464165.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-28
下一篇 2023-04-28

发表评论

登录后才能评论

评论列表(0条)

保存