我无法从此链接获取其他链接的ID

时间:2017-03-04 20:27:00

标签: php html

<!DOCTYPE html>
<html lang="en">
<?php
    session_start();
    include ("mysql_connect.php");
?>
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>MSWD ADMIN</title>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

      <link href="css/new.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="css/sb-admin.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

    <div id="wrapper">

        <!-- Navigation -->
        <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
         <div class="header">
         <div class="logo"><img  src="images/logo.png" height="80" width="80"><font color="white" size="6">&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp <u>&nbsp &nbsp &nbspMAKATI Social Welfare Department&nbsp &nbsp &nbsp</u></font></div>
         <img  src="images/header2.jpg" height="150" width="100%">
         </div>
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                 <a class="navbar-brand" href="adminpage.php">MAKATI Social Welfare Department</a>
            </div>
            <!-- Top Menu Items -->
            <ul class="nav navbar-right top-nav">
                <li class="dropdown">

                <li class="dropdown">

                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                        <li>
                              <a href="../admin.php"><i class="fa fa-fw fa-power-off"></i> Log Out</a>

                        <?
                            session_start();
                            session_unset();
                            session_destroy();
                            ob_start();
                            header("location:admin.php");
                            ob_end_flush();
                            exit();
                            ?>

                        </li>
                    </ul>
                </li>
            </ul>
            <!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->
            <div class="collapse navbar-collapse navbar-ex1-collapse">
                <ul class="nav navbar-nav side-nav">
                    <li>
                    <br>
                        <div class="welcomelogo"><img  src="images/welcomelogo.png" height="50" width="50"></div>
                        <div class="welcome"><h3>Welcome,<br> ADMIN</h3></div>
                        <br>
                    </li>

                    <li>
                        <a href="adminpage.php"><i class="fa fa-fw fa-bar-chart-o"></i>Report Generation</a>
                        <br>
                    </li>
                    <li>
                        <a href="mpms.php"><i class="fa fa-fw fa-user-md"></i> Missing Person Management</a>
                        <br>
                    </li>
                     <li>
                        <a href="fams.php"><i class="fa fa-fw fa-user"></i> Form Application Management</a>
                        <br>
                    </li>
                    <li>
                    <li class="active">
                        <a href="cms.php"><i class="fa fa-fw fa-group"></i>Content Management</a>
                    </li>
                    <li>
                        <a href="createaccount.php"><i class="fa fa-fw fa-group"></i>Create Account</a>
                        <br>
                    </li>


                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </nav>

        <div id="page-wrapper">

            <div class="container-fluid">

                <!-- Page Heading -->
                <div class="row">
                <br>
                <br>
                <br>
                    <div class="col-lg-12">
                        <h1 class="page-header">
                            Appointment Details
                        </h1>

                        <section class="webdesigntuts-workshop">
                                <form action="" method="">          
                                 <input type="search" placeholder="">               
                                  <button>Search</button>
                                 </form>
                            </section>
                            <li>
                              <a href="cms_add.php"><div class="addmember"><h5><b>Add Appointment</b></h5></div></a>
                            </li>
                            <br>
                           <br>
                           <br>
                    </div>
                </div>
                <!-- /.row -->
                <div class="jumbotron">
                    <div class="column">
                                <tr>    
                                    <td>
                                        <table id="appointment" border="1">
                                        <col width="8%"></col>
                                        <col width="10%"></col>
                                        <col width="15%"></col>
                                        <col width="20%"></col>
                                        <col width="15%"></col>
                                        <col width="10%"></col>
                                    <thead>
                                        <tr>
                                        <center>
                                            <th><center>ID</th>
                                            <th><center>Title</th>
                                            <th><center>Image</th>
                                            <th><center>Content</th>
                                            <th><center>Date</th>
                                            <th><center>Department</th> 
                                            <th><center>Action</center></th>  
                                        </center>

                                        </tr>
                                    </thead>

                <?php 
                $query="SELECT * from tbl_news";
                $result=mysql_query($query);


                while($row=mysql_fetch_array($result)){
            ?>
                <tr>    
                    <td><center><?php echo $row['news_id'];?></center></td>
                    <td><center><?php echo $row['news_title'];?></center></td>
                    <td><center><?php echo "<img src='uploads/news/".$row["news_image"]."'height='120' width=100% >";?></center></td>
                    <td><center><?php echo $row['news_content'];?></center></td>
                    <td><center><?php echo $row['news_date'];?></center></td>
                    <td><center><?php echo $row['news_department'];?></center></td>
                    <td>
                        <?php 

                        $id=$row['news_id'];
                        $_SESSION['id']=$id;

                        echo "<center>
                                <a href='cms_update.php?id=".$id." data-toggle='tooltip' title='Confirm'>
                                <i class='fa fa-check-square'></i>
                                </a>

                                <a href='appointmentDelete.php?id=".$id." data-toggle='tooltip' title='Cancel'>
                                    <i class='fa fa-minus-square'></i>
                                </a>
                            </center>";
                        ?>
                    </td>

                </tr>
            <?php
                }
            ?>
                        </div>
                <!-- /.row -->

            </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

    <!-- jQuery -->
    <script src="js/jquery.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>


</body>

</html>

我有这组代码,我想获取我选择更新它的行的news_id,但我的其他页面无法获取我想要更新的行的news_id。我无法真正理解如何将该ID转到另一页。

2 个答案:

答案 0 :(得分:1)

您可以从$_GET

访问它
<?php
if (isset($_GET['id']) {
    $id = $_GET['id'];
}

希望它有所帮助。

答案 1 :(得分:0)

您可以从上一个td

中写入的网址获取ID
<a href='cms_update.php?id=".$id." data-toggle='tooltip' title='Confirm'>
   <i class='fa fa-check-square'></i>
</a>

通过此代码,您可以获得ID为$ id = $ _ GET [&#39; id&#39;];