php程序设计经典300例,第36-38例

第36例:

使用分支语句加载不同网页主体



      



     $shop_id=$_GET['id'];
     switch($shop_id)
        {
            case "shop1"://如果ID为shop1
                 require("shop1.php");
                 break;
            case "shop2":
                 require("shop2.php");
                 break;
            case "shop3":
                 require("shop3.php");
                 break;
            default://默认的选择
                 require("shop1.php");
                 
        }
?>

第37例:

php万年历

header("Content-type:text/html;charset=utf-8");
date_default_timezone_set("Asia/Shanghai");//设置日期时区为中国时区
$today = time();
$year =@$_GET["year"];
$month = @$_GET["month"];
if($year=='') $year = date("Y",$today);
if($month=='') $month = date("m",$today);
if((int)$month==0){$year-=1;$month=12;}
$time = mktime(0,0,0,$month,1,$year);//格式化当前日期
$year = date('Y',$time);
$month = date('m',$time);
$days = date('t',$time);//当前月份一共有几天
$fstdw = date('N',$time);//当前月份第一天为星期几
echo "";
echo "";
echo"";
$str   = "";
$str .= "";
$str .= "";
$str .= "";
$str .= "";
$str .= "";
$str .= "";
echo $str;
echo "";
$rows = ceil(($days + $fstdw-1)/7);
$cd = 1;
for($i=0;$i<$rows;$i++){
echo "";
    for($j=0;$j<7;$j++){
     echo "";
    }
echo "";
}
echo "
";
$str   = "";
$str .= "
".$year."年 ";
$str .= "";
$str .= "
   ";
$str .= "";
$str .= "
".$month."月 ";
$str .= "";
$str .= "
";
echo $str;
echo "
";
     if($cd >= $fstdw && $cd<$days+$fstdw){
     $oday = $cd-$fstdw+1;
     if($oday == date('d',time())){
     echo "";
     }
     echo $oday;
     }else{
     echo ".";
     } 
     $cd++;
     echo "
";
?>


第38例:
index.php页面:


header("Content-Type:text/html;charset=utf-8");
MySQL_connect("localhost","root","123456") or die("数据库连接有误!");
mysql_select_db("student") or die("数据库选择有误!");
mysql_query("set names 'utf8'");
?>
 
    
        
        用户管理
        
    
    
        
        

        

            
                
                    
                    
                    
                    
                    
                
                                    //定义分页所需要的变量
                    $page=isset($_GET['page'])?$_GET['page']:1;//当前页
                    $pagesize=5; //每页显示的条数
                    //获取总条数数据
                    $sql="select count(*) from student";
                    $result=mysql_query($sql);
                    $maxrows=mysql_result($result,0,0);
                    $maxpage=ceil($maxrows/$pagesize);
                    //到达最后一页判断
                    if($page>$maxpage){
                    $page=$maxpage;
                    }
                    //到达第一页判断
                    if($page<1){
                        $page=1;
                    }
                    $offset=($page-1)*$pagesize;
                    $sql="select * from student limit {$offset},$pagesize";
                    $result=mysql_query($sql);
                    while($rows=mysql_fetch_assoc($result)){
                        echo "";
                        echo "";
                        echo "";
                        echo "";
                        echo "";
                        echo "";
                        echo "";
                    }
                ?>            
            
编号用户名邮件地址注册日期选择
{$rows['member_id']}{$rows['username']}{$rows['email']}".date("Y-m-d H:i:s",$rows['registertime']+8*3600)."

            
            

                

                                echo "当前{$page}/{$maxpage}页 共计{$maxrows}条信息    ";
                echo "首页    ";
                echo "上一页    ";
                echo "下一页    ";
                echo "最后一页";
                echo " ";
                ?>
                

        

        

    



check.php页面:

PRINT("
");
print_r($_POST);
exit();
header("Content-Type:text/html;charset=utf-8");
mysql_connect("localhost","root","123456") or die("数据库连接有误!");
mysql_select_db("student") or die("数据库选择有误!");
mysql_query("set names 'utf8'");

if(!empty($_POST['member_id'])){
$arr=$_POST['member_id'];
$str_key="";
foreach($arr as $key=>$value){
$sql="delete from student where member_id =".$value;
mysql_query($sql);
$str_key.=$value.",";
}
$new_str=substr($str_key,0,strlen($str_key)-1);
echo"";
}
?>

创新互联服务项目包括麟游网站建设、麟游网站制作、麟游网页制作以及麟游网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,麟游网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到麟游省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!


分享题目:php程序设计经典300例,第36-38例
URL网址:http://pwwzsj.com/article/gojhcg.html