置頂文章

九月 11, 2007

[架設技術]學生部落格自動化列表及文章數統計程式

為了方便管理學生部落格所寫的程式,自動列出學生部落格及張貼文章數。

下載:index-stu.zip 

------------程式碼------------------------- 

 

<html>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link rel="stylesheet" type="text/css" href="snes.css" media="all">
<body>
<?php
include_once("../config/config.properties.php");

/*
         產生學生帳號列表
    依據學生帳號:s998877 格式
   99代表年度¼Œ88袤»£表班級 77代表座號
                                       */

$class = array("5"=>"五年級",
  "51"=>"五年一班",
  "52"=>"五年二班",
  "53"=>"五年三班",
  "54"=>"五年四班",
  "55"=>"五年五班",
  "56"=>"五年六班",
  "6"=>"六年級",
  "61"=>"六年一班",
  "62"=>"六年二班",
  "63"=>"六年三班",
  "64"=>"六年四班",
  "65"=>"六年五班",
  "66"=>"六年六班") ;
echo "<h1>96學年度新生國小學生部落格帳號暨文章統計列表</H1><hr>";
/*95學年度學生帳號*/
$key_year ="95";
$key_grade ="5";
$key_config='s'.$key_year.$key_grade;


$db = mysql_pconnect($config["db_host"],$config["db_username"],$config["db_password"]);
mysql_select_db($config["db_database"]) ;
echo '<TABLE><TR>';
for($counter=1;$counter<7;$counter++)
{


$key = $key_config.$counter;
$query = "SELECT ".$config['db_prefix']."users.id,".$config['db_prefix']."users.user,".$config['db_prefix']."blogs.owner_id,".$config['db_prefix']."blogs.id AS blog_id,".$config['db_prefix']."articles.date,"."count(".$config['db_prefix']."articles.user_id) as num_posts";

$query = $query."  FROM ".$config['db_prefix']."users LEFT JOIN ".$config['db_prefix']."blogs ON (".$config['db_prefix']."users.id = ".$config['db_prefix']."blogs.owner_id)";
$query = $query." LEFT JOIN ".$config['db_prefix']."articles ON (".$config['db_prefix']."users.id = ".$config['db_prefix']."articles.user_id ";
if (!empty($_GET['time']))
{
 $query = $query." AND ".$config['db_prefix']."articles.date >= '".$_GET['time']."01000000'";
}
$query = $query.")";

 

$query = $query." where ".$config['db_prefix']."users.user LIKE '%".$key."%' AND ".$config['db_prefix']."blogs.status = 1 ";

$query = $query." GROUP BY ".$config['db_prefix']."users.id ORDER BY ".$config['db_prefix']."users.user";


$result=mysql_query($query) ;
$num_rows = mysql_num_rows($result) ;

echo "<TD><TABLE><TR><TH colspan='2'>".$class[$key_grade.$counter+10]."</TH></TR><TH>座號</TH><TH>文章數</TH><TR>";

for($i=0;$i<$num_rows;$i++)
{

echo "<TD>";
$row = mysql_fetch_array($result);
$tmp = explode($key_year.$key_grade.$counter,$row['user']);
  echo '<a href="../index.php?blogId='.$row["blog_id"].'" target="_blank">'.$tmp[1]."</TD>";
  echo "<TD>".$row['num_posts']."</TD></TR>";
}
echo "</TABLE></TD>";
}
echo "</TR></TABLE>";

 

/*96學年度學生帳號列表*/

$key_year ="96";
$key_grade ="5";
$key_config='s'.$key_year.$key_grade;

echo '<TABLE><TR>';
for($counter=1;$counter<7;$counter++)
{


$key = $key_config.$counter;
$query = "SELECT ".$config['db_prefix']."users.id,".$config['db_prefix']."users.user,".$config['db_prefix']."blogs.owner_id,".$config['db_prefix']."blogs.id AS blog_id,".$config['db_prefix']."articles.date,"."count(".$config['db_prefix']."articles.user_id) as num_posts";

$query = $query."  FROM ".$config['db_prefix']."users LEFT JOIN ".$config['db_prefix']."blogs ON (".$config['db_prefix']."users.id = ".$config['db_prefix']."blogs.owner_id)";
$query = $query." LEFT JOIN ".$config['db_prefix']."articles ON (".$config['db_prefix']."users.id = ".$config['db_prefix']."articles.user_id ";
if (!empty($_GET['time']))
{
 $query = $query." AND ".$config['db_prefix']."articles.date >= '".$_GET['time']."01000000'";
}
$query = $query.")";

 

$query = $query." where ".$config['db_prefix']."users.user LIKE '%".$key."%' AND ".$config['db_prefix']."blogs.status = 1 ";

$query = $query." GROUP BY ".$config['db_prefix']."users.id ORDER BY ".$config['db_prefix']."users.user";


$result=mysql_query($query) ;
$num_rows = mysql_num_rows($result) ;

echo "<TD><TABLE><TR><TH colspan='2'>".$class[$key_grade.$counter]."</TH></TR><TH>座號</TH><TH>文章數</TH><TR>";

for($i=0;$i<$num_rows;$i++)
{

echo "<TD>";
$row = mysql_fetch_array($result);
$tmp = explode($key_year.$key_grade.$counter,$row['user']);
  echo '<a href="../index.php?blogId='.$row["blog_id"].'" target="_blank">'.$tmp[1]."</TD>";
  echo "<TD>".$row['num_posts']."</TD></TR>";
}
echo "</TABLE></TD>";
}
echo "</TR></TABLE>";

?>
</body>
</html>


發佈者: 莊志明 at 21:35│  點閱次數 (6335)│ 修改文章管理迴響[專業成長]部落格架設技術

回應文章

 

發表迴響

(必要)
authimage
   

Powered by LifeType. Design by colaccl.com


Bad Behavior 已經阻擋了 229 個過去 7 天試圖闖關的垃圾迴響與引用。