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. 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. try this at this.
<td>input type="checkbox"></td>
For loop will automatically add checkbox in each row.