"; if ($first_info != ""){ echo "\n"; } $i = 0; while ($i<=20){ if ($$select_name == $i){ $panduan = " selected"; } else $panduan = ""; if (isset($array[$i])){ echo "\n"; $i++; } else { $i++; continue; } } echo ""; } // 适用于法规类后台上载 function upfile($file_path,$file,$up_path,$filename = ''){ global $HTTP_POST_FILES; $file_name = $HTTP_POST_FILES[$file][name]; //真实的原文件名 if (empty($filename)){ // 当$file_name变量不存在,copy的时候取原文件名 $filename = $file_name; } $file_array = explode(".",$file_name); $upfilename = $up_path.$filename; if (copy($file_path,$upfilename)){ // echo "".$file_name." 上传成功
"; } else{ echo "".$file_name." 上传失败
"; } } /* $text -- 文本 $upmethod -- 上传方式 0为文本 1为html $id -- 现已废除 */ function showmethod($text,$upmethod){ if ($upmethod==0){ $text = htmlspecialchars($text); $text = nl2br($text); $text = str_replace(" ", " ", $text); return $text; } else if ($upmethod==1){ $text = StripSlashes($text); return $text; } else { return "传送方式错误,请查找"; } } /* database_str($table,$str)($str) 函数说明: 本函数为返回控制面版中的一个字段值 参数(1个): $str:数据库中表的字段名称 */ function database_str($table,$str){ $sql = "select $str from ".$table; $result = mysql_query($sql); $magazine_array = mysql_fetch_array($result); return $magazine_array[$str]; } function database($sql){ $result = mysql_query($sql); $magazine_array = mysql_fetch_array($result); return $magazine_array; } /* database_select_check($table,$str) 函数说明:(初步用于网站后台分类处) 本函数为html页面中用于select表单选择时,判断选项与库中的值是否相似 */ function database_select_check($table,$name,$value,$webvalue = ''){ $sql = "select $name,$value from ".$table; $result = mysql_query($sql); $num = mysql_num_rows($result); for ($i=0; $i<$num; $i++){ $STR_ARRAY = mysql_fetch_array($result); echo "\n"; } } /* noadmininfo($shenfen) 中国畜牧业协会数据库 函数说明: 判断是否为高级管理员,不是就不得入内 参数(1个): $shenfen:管理员身份 */ function noadmininfo($shenfen,$daxiao){ if ($shenfen < $daxiao){ echo "您没有权利访问此页面"; exit(); } } // checkbox函数 function check_box($str,$value,$method){ $string_array = explode($method,$str); $num = count($string_array); $i = 0; while ($i < $num){ if ($string_array[$i] == $value){ echo $value." checked"; return; } $i++; if ($i == $num){ echo $value; } } } /* {各省显示} 函数说明: 参数: $select_name 传过来字段名 $array_value 值数组 $array_show 显示数组 $select 第一个option显示的内容!值为false */ function select_show($select_show_name,$array_value,$array_show,$select){ global $$select_show_name; $count = count($array_value); echo ""; } /* 清空目录中所有的文件函数 */ function del_file($topid_list_del){ $d = dir($topid_list_del); $filesnum = 0; while($entry=$d->read()) { if (is_dir($topid_list_del.$entry)){ // 如果是目录的话就跳出本次循环 continue; } else { //否则就对i加1 unlink($topid_list_del.$entry); $filesnum++; } } $d->close(); } /*日期转换函数 $ymd 日期 $type 类型 day month year $value 日期数 $aal + 或 -,+为延长日期,-为以前的日期 */ function willtime ($ymd,$type,$value,$aal){ $y = substr($ymd,0,4); $m = substr($ymd,5,2); $d = substr($ymd,8,2); if ($type == "year"){ if ($aal == "+"){ $y = $y + $value; } else if ($aal == "-"){ $y = $y - $value; } } if ($type == "month"){ if ($aal == "+"){ $m = $m + $value; } else if ($aal == "-"){ $m = $m - $value; } } if ($type == "day"){ if ($aal == "+"){ $d = $d + $value; } else if ($aal == "-"){ $d = $d - $value; } } $timestamp = mktime(0 ,0, 0,$m ,$d ,$y); $date_time_array = getdate($timestamp); $year = $date_time_array["year"]; $month = $date_time_array["mon"]; $day = $date_time_array["mday"]; if ($month < 10){ $month = "0".$month; } if ($day < 10){ $day = "0".$day; } return $year."-".$month."-".$day; } /*两日期求天数差 $ymd 日期 $type 类型 day month year $value 日期数 $aal + 或 -,+为延长日期,-为以前的日期 */ function read_sql($num,$length,$sql,$articlepath = ''){ global $self,$select; $result = mysql_query($sql); $numtwo = mysql_num_rows($result); if ($numtwo < $num){ $num = $numtwo; } for($i=0; $i<$num; $i++){ $news_array = mysql_fetch_array($result); $zhonglei = $news_array[zhonglei]; $zhonglei_array = explode(",",$zhonglei); $sqlzhonglei = "select articlepath from fenlei where yiji = $zhonglei_array[0] and erji = $zhonglei_array[1]"; $resultzhonglei = mysql_query($sqlzhonglei); $fenlei_array = mysql_fetch_array($resultzhonglei); // $articlepath = $self; $title = $news_array[title]; $id = $news_array[id]; $oripubdate = $news_array[oripubdate]; /* if ($length != false){ if (strlen($title) > $length){ $title = substr($title,0,$length); $title = $title.".."; } } */ echo "
".$title." [ ".substr($oripubdate,0,10)." ]
"; } } /* 文章显示页面导航 */ function article_daohang($id){ $sql = "select article_class from caaa_article where article_id = $id"; $STR_ARRAY = mysql_fetch_array(mysql_query($sql)); $sql = "select * from caaa_class2 where class_id = ".$STR_ARRAY['article_class']; $STR_ARRAY = mysql_fetch_array(mysql_query($sql)); $sql = "select * from caaa_class1 where class1_id = ".$STR_ARRAY['class1_id']; $TMP_ARRAY = mysql_fetch_array(mysql_query($sql)); $daohang_array = explode(",",$STR_ARRAY['class_top_id']); $class_num = count($daohang_array); for ($i=0; $i<$class_num; $i++){ $sql = "select * from caaa_class2 where class_id =".$daohang_array[$i]; $TMP2_ARRAY = mysql_fetch_array(mysql_query($sql)); if ($i == 0){ // 判断是否有导航路径,true则显示连接false则不显示连接 if ($TMP2_ARRAY['daohangpath']){ $aa = "".$TMP2_ARRAY['class_name'].""; } else { $aa = $TMP2_ARRAY['class_name']; } } else { // 判断是否有导航路径,true则显示连接false则不显示连接 if ($TMP2_ARRAY['daohangpath']){ $aa = $aa." >> ".$TMP2_ARRAY['class_name'].""; } else { $aa = $aa." >> ".$TMP2_ARRAY['class_name']; } } } return ">> ".$TMP_ARRAY['class1_name']." >> ".$aa; } function regulation_daohang($id){ $sql = "select regulation_class from caaa_regulation where regulation_id = $id"; $STR_ARRAY = mysql_fetch_array(mysql_query($sql)); $sql = "select * from caaa_class2 where class_id = ".$STR_ARRAY['regulation_class']; $STR_ARRAY = mysql_fetch_array(mysql_query($sql)); $sql = "select * from caaa_class1 where class1_id = ".$STR_ARRAY['class1_id']; $TMP_ARRAY = mysql_fetch_array(mysql_query($sql)); $daohang_array = explode(",",$STR_ARRAY['class_top_id']); $class_num = count($daohang_array); for ($i=0; $i<$class_num; $i++){ $sql = "select * from caaa_class2 where class_id =".$daohang_array[$i]; $TMP2_ARRAY = mysql_fetch_array(mysql_query($sql)); if ($i == 0){ $aa = $TMP2_ARRAY['class_name']; } else { $aa = $aa." >> ".$TMP2_ARRAY['class_name']; } } return ">> ".$TMP_ARRAY['class1_name']." >> ".$aa; } function standard_daohang($id){ $sql = "select standard_class from caaa_standard where standard_id = $id"; $STR_ARRAY = mysql_fetch_array(mysql_query($sql)); $sql = "select * from caaa_class2 where class_id = ".$STR_ARRAY['standard_class']; $STR_ARRAY = mysql_fetch_array(mysql_query($sql)); $sql = "select * from caaa_class1 where class1_id = ".$STR_ARRAY['class1_id']; $TMP_ARRAY = mysql_fetch_array(mysql_query($sql)); $daohang_array = explode(",",$STR_ARRAY['class_top_id']); $class_num = count($daohang_array); for ($i=0; $i<$class_num; $i++){ $sql = "select * from caaa_class2 where class_id =".$daohang_array[$i]; $TMP2_ARRAY = mysql_fetch_array(mysql_query($sql)); if ($i == 0){ $aa = $TMP2_ARRAY['class_name']; } else { $aa = $aa." >> ".$TMP2_ARRAY['class_name']; } } return ">> ".$TMP_ARRAY['class1_name']." >> ".$aa; } // 通知导航区别于其它导航 function message_daohang($id){ $sql = "select message_fenlei from caaa_message where message_id = $id"; $STR_ARRAY = mysql_fetch_array(mysql_query($sql)); // caaa_message表与其它不同,先做判断 if ($STR_ARRAY['message_fenlei'] == '1'){ $class = 379; } else if($STR_ARRAY['message_fenlei'] == '2'){ $class = 380; } $sql = "select * from caaa_class2 where class_id = ".$class; $STR_ARRAY = mysql_fetch_array(mysql_query($sql)); $sql = "select * from caaa_class1 where class1_id = ".$STR_ARRAY['class1_id']; $TMP_ARRAY = mysql_fetch_array(mysql_query($sql)); $daohang_array = explode(",",$STR_ARRAY['class_top_id']); $class_num = count($daohang_array); for ($i=0; $i<$class_num; $i++){ $sql = "select * from caaa_class2 where class_id =".$daohang_array[$i]; $TMP2_ARRAY = mysql_fetch_array(mysql_query($sql)); if ($i == 0){ $aa = $TMP2_ARRAY['class_name']; } else { $aa = $aa." >> ".$TMP2_ARRAY['class_name']; } } return ">> ".$TMP_ARRAY['class1_name']." >> ".$aa; } // 通知导航区别于其它导航 function association_daohang($id){ $sql = "select association_class from caaa_association where association_id = $id"; $STR_ARRAY = mysql_fetch_array(mysql_query($sql)); $sql = "select * from caaa_class2 where class_id = ".$STR_ARRAY['association_class']; $STR_ARRAY = mysql_fetch_array(mysql_query($sql)); $sql = "select * from caaa_class1 where class1_id = ".$STR_ARRAY['class1_id']; $TMP_ARRAY = mysql_fetch_array(mysql_query($sql)); $daohang_array = explode(",",$STR_ARRAY['class_top_id']); $class_num = count($daohang_array); for ($i=0; $i<$class_num; $i++){ $sql = "select * from caaa_class2 where class_id =".$daohang_array[$i]; $TMP2_ARRAY = mysql_fetch_array(mysql_query($sql)); if ($i == 0){ $aa = $TMP2_ARRAY['class_name']; } else { $aa = $aa." >> ".$TMP2_ARRAY['class_name']; } } return ">> ".$TMP_ARRAY['class1_name']." >> ".$aa; } /* 栏目显示页面导航 每类中具体的栏目号 */ function lanmu_daohang($class){ $sql = "select * from caaa_class1 where class1_id = $class"; $TMP_ARRAY = mysql_fetch_array(mysql_query($sql)); return ">> ".$TMP_ARRAY['class1_name']; } /* 栏目显示页面导航 */ function lanmu_daohang2($class){ $sql = "select * from caaa_class2 where class_id = $class"; $STR_ARRAY = mysql_fetch_array(mysql_query($sql)); $sql = "select * from caaa_class1 where class1_id = ".$STR_ARRAY['class1_id']; $TMP_ARRAY = mysql_fetch_array(mysql_query($sql)); $daohang_array = explode(",",$STR_ARRAY['class_top_id']); $class_num = count($daohang_array); for ($i=0; $i<$class_num; $i++){ $sql = "select * from caaa_class2 where class_id =".$daohang_array[$i]; $TMP2_ARRAY = mysql_fetch_array(mysql_query($sql)); if ($i == 0){ $aa = $TMP2_ARRAY['class_name']; } else { $aa = $aa." >> ".$TMP2_ARRAY['class_name']; } } return " >> ".$aa; } function article_title($num,$sql,$date,$showdatemethod,$number = ''){ $result = mysql_query($sql); $numtwo = mysql_num_rows($result); if ($numtwo < $num){ $num = $numtwo; } if ($num <= 0){ echo "未找到任何记录"; } else { for ($i=0; $i<$num; $i++){ $STR_ARRAY = mysql_fetch_array($result); $article_id = $STR_ARRAY['article_id']; $article_class = $STR_ARRAY['article_class']; $article_title = $STR_ARRAY['article_title']; if ($showdatemethod == "createdate"){ $showdate = $STR_ARRAY['createdate']; } else if ($showdatemethod == "article_oripubdate"){ $showdate = $STR_ARRAY['article_oripubdate']; } $path = database_str("caaa_class2 where class_id = ".$article_class,"linkpath"); if ($number != ''){ if (strlen($article_title) > $number){ $article_title = substr($article_title,0,$number); $article_title = $article_title.".."; } } if ($date != "nonedate"){ $d = " [ ".substr($showdate,0,10)." ]"; } else { $d = ''; } echo "".$article_title." ".$d."
\n"; } } } function related_article($table,$sql,$rows,$id){ $TMP_ARRAY = mysql_fetch_array(mysql_query($sql)); switch($table){ case ("caaa_article"): $id_name = "article_id"; // id名称 $relative_name = "article_relative"; // 关键词字段名 $relative = $TMP_ARRAY['article_relative']; // 关键词值 $class_name = "article_class"; // 类名 $class = $TMP_ARRAY['article_class']; // 类值 $title_name = "article_title"; // 标题字段名 $article_id = "article_id"; // 文章id字段名 $article_oripubdate = "article_oripubdate"; // 原发表日期字段名 break; case ("caaa_regulation"): $id_name = "regulation_id"; $relative_name = "regulation_relatedword"; $relative = $TMP_ARRAY['regulation_relatedword']; $class_name = "regulation_class"; $class = $TMP_ARRAY['regulation_class']; $title_name = "regulation_title"; $article_id = "article_id"; $article_oripubdate = "regulation_anndate"; break; case ("caaa_standard"): $id_name = "standard_id"; $relative_name = "standard_relatedword"; $relative = $TMP_ARRAY['standard_relatedword']; $class_name = "standard_class"; $class = $TMP_ARRAY['standard_class']; $title_name = "standard_title"; $article_id = "article_id"; $article_oripubdate = "standard_anndate"; break; } if ($TMP_ARRAY[$relative_name]){ $relative_array = explode("|",$relative); $relative_num = count ($relative_array); for ($i=1; $i<$relative_num-1; $i++){ if ($i==1){ $aa = "$relative_name like '%|$relative_array[$i]|%'"; } else { $aa = $aa." or $relative_name like '%|$relative_array[$i]|%'"; } } $related_sql = "select * from $table where ($aa) and $class_name = $class order by $id_name desc"; $result = mysql_query($related_sql); $num = mysql_num_rows($result); if ($num > 0){ if ($num > $rows){ $num = $rows; } for ($i=0; $i<$num; $i++){ $STR_ARRAY = mysql_fetch_array($result); if ($id != $STR_ARRAY[$id_name]){ $linkpath = database_str("caaa_class2 where class_id = $class","linkpath"); echo ""; echo $STR_ARRAY[$title_name]." \n $STR_ARRAY[$article_oripubdate]
\n"; } } } else echo ''; } } function stat_user($table,$str,$idname,$id){ mysql_query("update ".$table." set ".$str." = ".$str." + 1 where ".$idname." = ".$id); // echo "update ".$table." set ".$str." = ".$str." + 1 where ".$idname." = ".$id; } /* repeat($sql) 重复数据判断函数 函数说明: 可判断是否有重复数据 参数(1个): $sql:查询sql语句 */ function repeat($sql){ $result = mysql_query($sql); $num = mysql_num_rows($result); if ($num>0){ return true; } else return false; } /* difference_nowdate($y,$m,$d) 指定日期与现在日期差计算 说明: 返回差额天数 */ function difference_nowdate($y,$m,$d){ // 取得指定日期 $willdate = mktime(0,0,0,$m,$d,$y); // 现在日期 $now = time(); // 两日期绝对值 $difference = abs($now - $willdate); // 返回两天相差日期 return Floor($difference/(3600*24)); } /* difference_nowdate($y,$m,$d) 正确截取中文字符函数 说明: 返回差额天数 */ function msubstr($str,$strlen) { for($i=0;$i<$strlen;$i++) { if(ord(substr($str,$i,1))>0xa0) { $tmpstr.=substr($str,$i,2); $i++; } else $tmpstr.=substr($str,$i,1); } return $tmpstr; } /* 文章检测函数 说明: 检查是否本栏目文章,返回id 参数: $class 大类号 $table 表名 $class_name 本栏目小类在表中的名字 $id_name 本栏目id在表中的名字 $article_id id号 */ function check_article($class,$table,$class_name,$id_name,$article_id){ // 读取本篇文章class号 $STR_ARRAY = mysql_fetch_array(mysql_query("select * from ".$table." where ".$id_name." = ".$article_id)); $STR_ARRAY = mysql_fetch_array(mysql_query("select * from caaa_class2 where class_id = ".$STR_ARRAY[$class_name])); if ($class != $STR_ARRAY['class1_id']){ return $article_id = ''; } else { return $article_id; } } /** 定义日期显示方式: '' 为不显示 'YM' 显示年月 'ymd' 显示年月日 **/ function show_date($method,$date){ switch ($method){ case "ymd": return "".substr($date,0,10).""; break; case "ym": return "".substr($date,0,7).""; break; case "mdi": return "".substr($date,5,5).""; break; case "Ymd": return "".substr($date,2,8).""; break; case "Ymdi": return "".substr($date,2,8).""; break; case "[Ymd-r]": return "[".substr($date,2,8)."]"; break; case "none": return ''; break; default: return $date; } } /* 导出大类所有小类id号,返回一个数组 */ function class1_array($id){ $result = mysql_query("select class_id from caaa_class2 where class1_id = $id"); $num = mysql_num_rows($result); for ($i=0; $i<$num; $i++){ $STR_ARRAY = mysql_fetch_array($result); $a_array[$i] = $STR_ARRAY['class_id']; } return $a_array; } /* 导出其中一个栏目所有下级id号,返回一个数组 */ function class2_array($id){ $result = mysql_query("select class1_id,class_top_id from caaa_class2 where class_id = $id"); $STR_ARRAY = mysql_fetch_array($result); $result = mysql_query("select class_id from caaa_class2 where class1_id = ".$STR_ARRAY['class1_id']." and (class_top_id like '".$STR_ARRAY['class_top_id'].",%' or class_top_id = '".$STR_ARRAY['class_top_id']."')"); $num = mysql_num_rows($result); for ($i=0; $i<$num; $i++){ $STR_ARRAY = mysql_fetch_array($result); $a_array[$i] = $STR_ARRAY['class_id']; } return $a_array; } /* 导出where函数 */ function class_where($class_array,$str_name){ $market_pig_count = count($class_array); for ($i=0;$i<$market_pig_count;$i++){ if ($i==0){ $where = $str_name." = ".$class_array[0]; } else { $where = $where." or ".$str_name." = ".$class_array[$i]; } } return $where; } function class_unwhere($class_array,$str_name){ $market_pig_count = count($class_array); for ($i=0;$i<$market_pig_count;$i++){ if ($i==0){ $where = $str_name." <> ".$class_array[0]; } else { $where = $where." and ".$str_name." <> ".$class_array[$i]; } } return $where; } #write by yayu function createStaticPage($sourcePage,$objectPage)#来源文件,目标文件 { #得到两个参数,一个是来源文件地址,一个是需要生成的静态页面地址 global $db; #数据库连接用的,在$sourcePage中需要用到 ob_start(); #打开缓冲区,相当于做了一个用来存放东西的箱子 include $sourcePage; #在缓冲区中释放页面,从这个代码中应该可以明白一点:那就是$sourcePage页面单独查看的时候,它是可以显示的!这是关键之所在,如果后面不加ob_end_clean()函数,那在执行程序的时候你看见$sourcePage页面的内容。 $cons=ob_get_contents(); #得到缓冲区中的内容,这里的内容就是HTML代码!这相当于把箱子里面的东西转给了一个人! ob_end_clean(); #清除缓冲区的内容,把箱子里面的东西转给他人后,打扫卫生,不打扫卫生的后果是让他人可以看见箱子的东西,也即可以看见$sourcePage页面的内容 $fp=fopen($objectPage,"wb") or die("静态生成时打开文件".$objectPage."时出错"); fwrite($fp,$cons); #把HTML代码写入静态文件中! fclose($fp); return true; } #write by yayu function createStaticArticle($sourcePage,$objectPage,$ID)#来源文件,目标文件 { #得到两个参数,一个是来源文件地址,一个是需要生成的静态页面地址 global $db; #数据库连接用的,在$sourcePage中需要用到 ob_start(); #打开缓冲区,相当于做了一个用来存放东西的箱子 include $sourcePage; #在缓冲区中释放页面,从这个代码中应该可以明白一点:那就是$sourcePage页面单独查看的时候,它是可以显示的!这是关键之所在,如果后面不加ob_end_clean()函数,那在执行程序的时候你看见$sourcePage页面的内容。 $cons=ob_get_contents(); #得到缓冲区中的内容,这里的内容就是HTML代码!这相当于把箱子里面的东西转给了一个人! ob_end_clean(); #清除缓冲区的内容,把箱子里面的东西转给他人后,打扫卫生,不打扫卫生的后果是让他人可以看见箱子的东西,也即可以看见$sourcePage页面的内容 $fp=fopen($objectPage,"wb") or die("静态生成时打开文件".$objectPage."时出错"); fwrite($fp,$cons); #把HTML代码写入静态文件中! fclose($fp); return true; } #write by yayu function createStaticCloseArticle($sourcePage,$objectPage,$ID,$check)#来源文件,目标文件 { #得到两个参数,一个是来源文件地址,一个是需要生成的静态页面地址 global $db; #数据库连接用的,在$sourcePage中需要用到 ob_start(); #打开缓冲区,相当于做了一个用来存放东西的箱子 include $sourcePage; #在缓冲区中释放页面,从这个代码中应该可以明白一点:那就是$sourcePage页面单独查看的时候,它是可以显示的!这是关键之所在,如果后面不加ob_end_clean()函数,那在执行程序的时候你看见$sourcePage页面的内容。 $cons=ob_get_contents(); #得到缓冲区中的内容,这里的内容就是HTML代码!这相当于把箱子里面的东西转给了一个人! ob_end_clean(); #清除缓冲区的内容,把箱子里面的东西转给他人后,打扫卫生,不打扫卫生的后果是让他人可以看见箱子的东西,也即可以看见$sourcePage页面的内容 $fp=fopen($objectPage,"wb") or die("静态生成时打开文件".$objectPage."时出错"); fwrite($fp,$cons); #把HTML代码写入静态文件中! fclose($fp); return true; } ## 验证文件重名 function echofile($file,$newfile){ $d = dir($file); // echo "Handle: ".$d->handle."
\n"; // echo "Path: ".$d->path."
\n"; while (false !== ($entry = $d->read())) { // echo $entry."
\n"; if ($entry == $newfile){ return false; } } $d->close(); } #自动报价xml文件生成函数 function createStaticPage_price($sourcePage,$objectPage,$id,$priceaction,$articleid)#来源文件,目标文件 { #得到两个参数,一个是来源文件地址,一个是需要生成的静态页面地址 global $db; #数据库连接用的,在$sourcePage中需要用到 ob_start(); #打开缓冲区,相当于做了一个用来存放东西的箱子 include $sourcePage; #在缓冲区中释放页面,从这个代码中应该可以明白一点:那就是$sourcePage页面单独查看的时候,它是可以显示的!这是关键之所在,如果后面不加ob_end_clean()函数,那在执行程序的时候你看见$sourcePage页面的内容。 $cons=ob_get_contents(); #得到缓冲区中的内容,这里的内容就是HTML代码!这相当于把箱子里面的东西转给了一个人! ob_end_clean(); #清除缓冲区的内容,把箱子里面的东西转给他人后,打扫卫生,不打扫卫生的后果是让他人可以看见箱子的东西,也即可以看见$sourcePage页面的内容 $fp=fopen($objectPage,"wb") or die("静态生成时打开文件".$objectPage."时出错"); fwrite($fp,$cons); #把HTML代码写入静态文件中! fclose($fp); return true; } // 读出管理员的真实姓名,生成一个数组返回值 function administrator_user(){ global $administrator_array; $sql = "select * from caaa_administrator"; $result = mysql_query($sql); $num = mysql_num_rows($result); for ($i=0; $i<$num; $i++){ $STR_ARRAY = mysql_fetch_array($result); $administrator_array[$STR_ARRAY['admin_username']] = $STR_ARRAY['admin_name']; } return $administrator_array; } ?>