第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 ""; $str = ""; $str .= " ".$year."年 "; $str .= ""; $str .= " "; $str .= ""; $str .= " ".$month."月 "; $str .= ""; $str .= " "; echo $str; 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 ""; if($cd >= $fstdw && $cd<$days+$fstdw){ $oday = $cd-$fstdw+1; if($oday == date('d',time())){ echo ""; } echo $oday; }else{ echo "."; } $cd++; echo " | ";
}
echo "
";
}
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'");
?>
用户管理 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例
文章地址:http://bzwzjz.com/article/gojhcg.html