• About-PHP-02


    如果要给table里面的td添加颜色,有两种方法:

     1 <html>
     2 <head>
     3     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
     4     <!--    第一种是用stylecss-->
     5     <style type="text/css">
     6         tr:nth-child(even){  /*even:偶数   odd:基数*/
     7             background-color: red;
     8         }
     9     </style>
    10 </head>
    11 <body>
    12 
    13 </body>
    14 <!--    第二种是用js+css-->
    15 <script>
    16     function changeColor(){ //改变颜色的函数
    17         var trs = document.getElementsByTagName("tr"); //找到table中的所有的tr
    18         for(var i=0;i<trs.length;i++){
    19             if( i%2 == 0){
    20                 trs[i].style.background="#cad9ea";
    21             }
    22         }
    23     }
    24     window.onload = changeColor;
    25 
    26 </script>
    27 </html>
    1 <?php
    2 $sql = "select * from movie limit 0,5"; //0:从第一条显示     5:显示5条
    3 
    4 $totalPage = $count % $pageSize == 0 ? intval($count / $pageSize) :  intval($count / $pageSize) + 1;
    5 //intval是强制换成整型
    6 //intval($count / $pageSize) =(int)($count / $pageSize) 
    7 echo $totalPage;
    8 ?>
     1 <html>
     2 <head>
     3     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
     4     <style>
     5         tr:nth-child(even){
     6         background: #cad9ea;
     7         }
     8     </style>
     9 </head>
    10 <body>
    11 <table border="1">
    12     <tr style="background-color: #afbcff">
    13         <td>序号</td>
    14         <td>电影名称</td>
    15         <td>主演</td>
    16         <td>类型</td>
    17         <td>操作</td>
    18     </tr>
    19     <?php
    20     $conn = mysql_connect("localhost","","") or die("链接数据库失败");
    21     mysql_select_db("test");
    22     mysql_query("set names 'utf8'");
    23 
    24     $page = "";
    25     if(@$_GET['page']){
    26         $page = $_GET['page'];
    27     }else{
    28         $page = 1;
    29     }
    30 
    31     $pageSize = 3;
    32     $sum = ($page-1)*$pageSize;
    33 
    34     $sql = "select * from movie limit $sum,$pageSize";
    35     echo $sql;
    36     $result = mysql_query($sql) or die(mysql_error());
    37 
    38     $sqlAll = "select * from movie";
    39     $resultAll = mysql_query($sqlAll) or die(mysql_error());
    40 
    41     $count = mysql_num_rows($resultAll);
    42 
    43     $n = 0;
    44 
    45     while($row = mysql_fetch_array($result)){
    46         ?>
    47         <tr>
    48             <td><?php echo $row['id'] ?></td>
    49             <td><a href="movie_detail.php?id=<?php echo $row['id'] ?>"> <?php echo $row['movieName'] ?> </a></td>
    50             <td><?php echo $row['actor'] ?></td>
    51             <td><?php echo $row['type'] ?></td>
    52             <td><a href="#">删除</a></td>
    53         </tr>
    54     <?php
    55         $n++;
    56     }
    57     mysql_close($conn);
    58     ?>
    59 </table>
    60 
    61 <span>共有 <?php echo $count ?>电影</span>
    62 <span>共有<?php
    63     $totalPage = $count % $pageSize == 0? intval($count / $pageSize) : intval($count / $pageSize)+1;
    64     echo $totalPage;
    65     ?>页</span>
    66 <a href="movie_About.php?page=<?php echo $page-1 ?>">上一页</a>
    67 
    68 <?php
    69 for($i=1;$i<=$totalPage;$i++){
    70     ?>
    71     <a href="movie_About.php?page=<?php echo $i ?>"><?php echo $i ?></a>
    72 <?php
    73 }
    74 ?>
    75     <a href="movie_About.php?page=<?php if($page >= $totalPage){echo $totalPage;}else{echo $page+1;} ?>">下一页</a>
    76 
    77 跳转到 <input type="text" name="page" maxlength="5" size="5" id="txt"/>78 </body>
    79 </html>
     1 <html>
     2 <head>
     3     <title></title>
     4     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
     5 </head>
     6 <?php
     7 $conn = mysql_connect("localhost","","") or die("链接数据库失败");
     8 mysql_select_db("test");
     9 mysql_query("set names 'utf8'");
    10 
    11 if(@$_GET['id']){
    12     $id = $_GET['id'];
    13     $sql = "select * from movie where id = $id";
    14     $r = mysql_query($sql);
    15     $row = mysql_fetch_array($r);
    16 }
    17 ?>
    18 <body>
    19 <form action="mov_update.php" method="post">
    20     <input type="hidden" value="<?php echo $row['id'] ?>" name="id" readonly="readonly"/>
    21     电影名称: <input type="text" value="<?php echo $row['movieName'] ?>" name="movieName"/> <br/>
    22     主    演: <input type="text" value="<?php echo $row['actor'] ?>" name="actor"/> <br/>
    23     <input type="submit" name="submit" value="修改"/>
    24 </form>
    25 </body>
    26 
    27 </html>
     1 <?php
     2 $conn = mysql_connect("localhost","","") or die("链接数据库失败");
     3 mysql_select_db("test");
     4 mysql_query("set names 'utf8'");
     5 
     6 if(@$_POST['submit']){
     7     $id = $_POST['id'];
     8     $moviename = $_POST['movieName'];
     9     $actor = $_POST['actor'];
    10     $sql = "UPDATE `movie` SET `movieName`='$movieName',`actor`='$actor' WHERE id = $id";
    11     $r = mysql_query($sql);
    12     if($r){
    13         echo "<script>location.href='movie_About.php'</script>";
    14     }
    15 }
    16 ?>
     1 <html>
     2 <head>
     3     <title></title>
     4     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
     5 </head>
     6 <body>
     7 
     8 <table border="1">
     9     <tr style="background-color: #afbcff">
    10         <td>序号</td>
    11         <td>电影名称</td>
    12         <td>主演</td>
    13         <td>时长</td>
    14         <td>类型</td>
    15         <td>导演</td>
    16         <td>描述</td>
    17     </tr>
    18 <?php
    19 if(isset($_GET['movieid'])){
    20     $id = $_GET['movieid'];
    21 
    22     $conn = mysql_connect("localhost","","") or die("链接数据库失败");
    23     mysql_select_db("test");
    24     mysql_query("set names 'utf8'");
    25 
    26     $sql = "select * from movie where id = $id";
    27     $result = mysql_query($sql);
    28     $row = mysql_fetch_array($result);
    29 
    30 
    31     echo "<td>".$row['id']."</td>";
    32     echo "<td>".$row['movieName']."</td>";
    33     echo "<td>".$row['actor']."</td>";
    34     echo "<td>".$row['timer']."</td>";
    35     echo "<td>".$row['type']."</td>";
    36     echo "<td>".$row['dirctor']."</td>";
    37     echo "<td>".$row['intro']."</td>";
    38 }else{
    39     echo "<script>alert('you dont request this page by url!,please into by A tag');</script>";
    40 }
    41 ?>
    42 </table>
    43 </body>
    44 </html>
  • 相关阅读:
    阿里架构师说Kafka工作原理归纳,实践通俗易懂!我咋不信呢
    2020做Java的都看这篇文章,面试一次过、升职加薪,赶快来Get
    IDEA最牛配置,众享丝滑
    在IDEA中搭建Java源码学习环境并上传到GitHub上
    Linux基本命令
    正向代理与反向代理
    Spring Boot中使用MyBatis详解
    ftp命令详解
    CentOS7设置中文字符集
    CentOS7计划任务crontab
  • 原文地址:https://www.cnblogs.com/a-moemiss/p/3699976.html
Copyright © 2020-2023  润新知