简体   繁体   English

使用php和html在数据库中的每一行中包括复选框

[英]Including check box to each row of my data in database using php and html

I have a table called idean5 which has my data.And i'm displaying that data using php on my webpage ,now i want to add a tick box for each row of my data,actually i want to move particular rows from this table idean5 to other table called idean4. 我有一个名为idean5的表,其中包含我的数据。我正在用php在我的网页上显示该数据,现在我想为我的数据的每一行添加一个复选框,实际上我想从该表中移动特定的行idean5到另一个名为idean4的表。 so when some one ticks the boxes and click on a move hyperlink button.this data should be moved. 因此,当有人在方框中打钩并单击移动超链接按钮时,该数据应被移动。

code for this: 为此的代码:

<?php
include('db.php');
require_once('auth.php');    //include of db config file
include ('paginate.php'); //include of paginat page

$per_page = 15;         // number of results to show per page
$result = mysql_query("SELECT * FROM idean5");
$total_results = mysql_num_rows($result);
$total_pages = ceil($total_results / $per_page);//total pages we going to have

//-------------if page is setcheck------------------//
if (isset($_GET['page'])) {
  $page = intval($_GET['page']);
  if ($page <= 0){
    $page = 1;}
    $show_page = $_GET['page'];             //it will telles the current page
    if ($show_page > 0 && $show_page <= $total_pages) {
        $start = ($show_page - 1) * $per_page;
        $end = $start + $per_page;
    } else {
        // error - show first set of results
        $start = 0;              
        $end = $per_page;
    }
} else {
    // if page isn't set, show first set of results
    $start = 0;
    $end = $per_page;
}
// display pagination


$tpages=$total_pages;

?>
<!DOCTYPE html>
<html>
<head>
<style>
body { background: #eee url() no-repeat center 0px; padding-top:5px;}
ul {
    list-style-type: none;
    margin: center;
    padding: center;
    overflow: hidden;
    background-color: #333;
}

li {
    float: left;
}

li a, .dropbtn {
    display: inline-block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}

li a:hover, .dropdown:hover .dropbtn {
    background-color: green;
}

li.dropdown {
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
}

.dropdown-content a:hover {background-color: #f1f1f1}

.dropdown:hover .dropdown-content {
    display: block;
}
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <style type="text/css">
.logo
{
    text-align: center;
}
.container{

}
</style>
<h3 align="right">WELCOME <?php echo $_SESSION['SESS_FIRST_NAME'];?>!</h3>
</head>
<body>
<ul>
  <li><a href="requestinput.php">REQUEST FOR TND</a></li>
  <li class="dropdown">
    <a href="#" class="dropbtn">UPLOAD TND</a>
    <div class="dropdown-content">
      <a href="displayingrequests.php">TND REQUESTS</a>
      <a href="import.php">UPLOAD TND</a>
    </div>
  </li>

  <li><a href="Combined_Status.php">STATUS SEARCH</a></li>
  <li><a href="testformsimple.php">SEARCH</a></li>
  <li><a href="approvalinput.php">APPROVAL</a></li>
  <li><a href="index.php">LOGOUT</a></li>

</ul>
<div class="container">
        <div class="row">
            <div class="logo">


                </a>
            </div>
        </div>
        <div class="row">

                 <?php
                    $reload = $_SERVER['PHP_SELF'] . "?tpages=" . $tpages;
                    echo '<div class="pagination"><ul>';
                    if ($total_pages > 1) {
                        echo paginate($reload, $show_page, $total_pages);
                    }

                    echo "</ul></div>";
                    // display data in table
                    echo "<table border='1'>                  
                    <tr>
                    <th>TND ID</th>
                    <th>Site Name S1</th>
                    <th>Site Name S2</th>
                    <th>Idea ID S1</th>
                    <th>Idea ID S2</th>
                    <th>O N M Remarks</th>
                    <th>Planning Remarks</th>
                    <th>Projects Remarks</th>

                    </tr>";
                    // loop through results of database query, displaying them in the table 
                    for ($i = $start; $i < $end; $i++) {
                        // make sure that PHP doesn't try to show results that don't exist
                        if ($i == $total_results) {
                            break;
                        }

                        // echo out the contents of each row into a table
                        echo "<tr>";
                        echo '<td>' . mysql_result($result, $i, 'TND_ID') . '</td>';
                        echo '<td>' . mysql_result($result, $i, 'Site_name_S1') . '</td>';
                        echo '<td>' . mysql_result($result, $i, 'Site_name_S2') . '</td>';
                        echo '<td>' . mysql_result($result, $i, 'Idea_ID_S1') . '</td>';
                        echo '<td>' . mysql_result($result, $i, 'Idea_ID_S2') . '</td>';
                        if (mysql_result($result, $i, 'O_M_Remarks')) {
                           echo '<td>' . mysql_result($result, $i, 'O_M_Remarks').'</td>';
                        }
                        else {
                          echo '<td>' . mysql_result($result, $i, 'O_M_Remarks') . '<a href="o&mstatusinput.php ? TND_ID='.mysql_result($result, $i, 'TND_ID').'">O N M remarks</a> </td>';
                        }
                        if (mysql_result($result, $i, 'Planning_Remarks')) {
                           echo '<td>' . mysql_result($result, $i, 'Planning_Remarks').'</td>';
                        }
                        else {
                          echo '<td>' . mysql_result($result, $i, 'Planning_Remarks') . '<a href="planningstatusinput.php ? TND_ID='.mysql_result($result, $i, 'TND_ID').'">Planning remarks</a> </td>';
                        }
                        if (mysql_result($result, $i, 'O_M_Remarks')) {
                           echo '<td>' . mysql_result($result, $i, 'Projects_Remarks').'</td>';
                        }
                        else {
                          echo '<td>' . mysql_result($result, $i, 'Projects_Remarks') . '<a href="projectsstatusinput.php ? TND_ID='.mysql_result($result, $i, 'TND_ID').'">Projects remarks</a> </td>';
                        }

                        echo "</tr>";
                    }       
                    // close table>
                echo "</table>";
            // pagination
            ?>
            </div>
        </div>
    </div>
</div>
</body>
</html>

In "//echo out the contents of each row into a table" portion. 在“ // echo出每一行的内容到一个表”部分。 try this at this. 尝试这个。

<td>input type="checkbox"></td>

For loop will automatically add checkbox in each row. For循环将在每行中自动添加复选框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从PHP中的复选框选中的数据库中保存一行数据 - How to save a row of data from database selected by a check box in PHP 如何通过使用PHP,javascript和html单击从数据库中检索到的数据来编辑每行属性 - how each row attributes can be edited by clicking on retrieved data from the database using PHP, javascript and html 我正在尝试使用复选框删除一行数据,当我单击删除时,我的php应该删除该行 - I am trying to delete a row of data using a check box, when I click on delete my php should delete the row 如何使用 php 从数据库的每一行中获取 select 数据 - How to select data from each row of database using php HTML PHP复选框 - HTML PHP check box 如何使用php和html从表单输入框中检查用户的输入对应于mysql中数据库的结果 - How to check the input of a user from a form input box using php and html corresponds to a result from the database in mysql 使用php在mysql中插入复选框数据 - Inserting check box data in mysql using php 无法使用PHP将html表单的数据插入到数据库中 - Can not get data to insert to my database using html forms with PHP 使用Codeigniter将HTML标记(包括PHP脚本)存储在数据库中 - Storing HTML tags including PHP script in the database using Codeigniter 如何使用php在数据库中的每个项目旁边放置一个输入框 - how to put an input box next to each item in a database using php
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM