简体   繁体   中英

I can't get the id from this link to other link

<!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>

I have this set of codes, and I want to get the news_id of the row I selected to update it, but my other page can't get the news_id of the row I want to update. I can't really understand properly how to get that id to the other page.

You can access it from $_GET :

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

Hope it helps.

You can get id from url that you written in your last td

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

From this code you can get id like $id=$_GET['id'];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM