91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

php程序設計經典300例,第36-38例

發布時間:2020-07-22 14:24:56 來源:網絡 閱讀:605 作者:鐘澤鋒 欄目:web開發

第36例:

使用分支語句加載不同網頁主體

<div id="header">
<!--頁面導航條-->
    <ul>
         <li><a href="?id=shop1">基本商品</a></li>
         <li><a href="?id=shop2">推薦商品</a></li>
         <li><a href="?id=shop3">分類商品</a></li>
    </ul>
    
</div>
<div id="content">
       <!--此處動態更改主體內容-->
</div>


<?php
     $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萬年歷

<?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 "<table border=1 width=260 cellspacing=0 cellpadding=0 align=center bgcolor=#cccccc>";
echo "<tr><td colspan=7 class=title>";
$str   = "<a href=?year=".($year-1)."&month=".$month.">";
$str .= "</a> ".$year."年 ";
$str .= "<a href=?year=".($year+1)."&month=".$month.">";
$str .= "</a>   ";
$str .= "<a href=?year=".$year."&month=".($month-1).">";
$str .= "</a> ".$month."月 ";
$str .= "<a href=?year=".$year."&month=".($month+1).">";
$str .= " </a>";
echo $str;
echo "</td></tr>";
echo"<tr>";
$str   = "<td>一</td>";
$str .= "<td>二</td>";
$str .= "<td>三</td>";
$str .= "<td>四</td>";
$str .= "<td>五</td>";
$str .= "<td>六</td>";
$str .= "<td>七</td>";
echo $str;
echo "</td>";
$rows = ceil(($days + $fstdw-1)/7);
$cd = 1;
for($i=0;$i<$rows;$i++){
echo "<tr>";
    for($j=0;$j<7;$j++){
     echo "<td>";
     if($cd >= $fstdw && $cd<$days+$fstdw){
     $oday = $cd-$fstdw+1;
     if($oday == date('d',time())){
     echo "<font color='red'><b><u>";
     }
     echo $oday;
     }else{
     echo ".";
     } 
     $cd++;
     echo "</td>";
    }
echo "</tr>";
}
echo "</table>";
?>


第38例:
index.php頁面:


<?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'");
?>
<html> 
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
        <title>用戶管理</title>
        <style>
            body{text-align:center;}
            #header{width:600px;height:50px;margin:10px;background:#E3EFFB;line-height:50px;font-size:20px;}
            #main{width:600px;margin:10px;margin:0px auto;}
            #main table{widt h:600px;background:#E3EFFB;cellspacing:1px;text-align:center;}
            #main table tr{background:white;}
            #main table img{border:0px;}
            #page{width:600px;height:30px;background:#E3EFFB;line-height:30px;}
        </style>
    </head>
    <body>
        <div id="header">網站管理中心--會員列表</div>
        <div id="main">
        <form name="myForm" action="check.php" method="post">
            <table>
                <tr>
                    <th width="100">編號</th>
                    <th width="150">用戶名</th>
                    <th width="200">郵件地址</th>
                    <th width="200">注冊日期</th>
                    <th width="50">選擇</th>
                </tr>
                <?php
                    //定義分頁所需要的變量
                    $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 "<tr>";
                        echo "<td>{$rows['member_id']}</td>";
                        echo "<td>{$rows['username']}</td>";
                        echo "<td>{$rows['email']}</td>";
                        echo "<td>".date("Y-m-d H:i:s",$rows['registertime']+8*3600)."</td>";
                        echo "<td><input type='checkbox' value='{$rows['member_id']}' name='member_id[]'></td>";
                        echo "</tr>";
                    }
                ?>            
            </table>
            
            <br/>
                <div id="page">
                <?php
                echo "當前{$page}/{$maxpage}頁 共計{$maxrows}條信息    ";
                echo "<a href='user.php?page=1'>首頁</a>    ";
                echo "<a href='user.php?page=".($page-1)."'>上一頁</a>    ";
                echo "<a href='user.php?page=".($page+1)."'>下一頁</a>    ";
                echo "<a href='user.php?page=".$maxpage."'>最后一頁</a>";
                echo " <input type='submit' value='批量刪除'>";
                ?>
                </div>
        </form>
        </div>
    </body>
<html>


check.php頁面:

<?php
PRINT("<PRE>");
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"<script>alert('刪除編號為".$new_str."的信息成功!');location='user.php'</script>";
}
?>

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

永清县| 孙吴县| 阜新市| 无棣县| 方山县| 峨山| 游戏| 南昌市| 普兰店市| 金坛市| 定襄县| 永平县| 鲁山县| 昔阳县| 玉门市| 浦北县| 巴里| 连山| 龙江县| 镇远县| 棋牌| 饶平县| 腾冲县| 大同县| 镇平县| 鹤庆县| 五峰| 阳原县| 常宁市| 罗田县| 宁化县| 周口市| 南城县| 进贤县| 万载县| 璧山县| 青岛市| 金堂县| 大渡口区| 岗巴县| 武山县|