File: //proc/self/cwd/admin/view_images.php
<?php
session_start();
// set time-out period (in seconds)
$inactive = 600;
// check to see if $_SESSION["timeout"] is set
if (isset($_SESSION["timeout"])) {
// calculate the session's "time to live"
$sessionTTL = time() - $_SESSION["timeout"];
if ($sessionTTL > $inactive) {
session_destroy();
header("Location: logout.php");
}
}
$_SESSION["timeout"] = time();
include '../connect.php';
if($_SESSION['username'] == '') { header('location:index.php'); }
$query = mysql_query("select * from images order by image_id desc");
if(isset($_GET['delete'])) {
$delete = mysql_query("delete from images where image_id = '".$_GET['delete']."'");
header('location:view_images.php');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Suraj Automobiles</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="keywords" content="Your keywords">
<meta name="author" content="Your name">
<link rel="stylesheet" type="text/css" media="screen" href="../styles.css">
<!--<link href='http://fonts.googleapis.com/css?family=Ruthie' rel='stylesheet' type='text/css'>-->
<script src="../js/jquery-1.7.2.min.js"></script>
<script src="../js/menu.js"></script>
<script type="text/javascript">
function Pager(tableName, itemsPerPage) {
this.tableName = tableName;
this.itemsPerPage = itemsPerPage;
this.currentPage = 1;
this.pages = 0;
this.inited = false;
this.showRecords = function(from, to) {
var rows = document.getElementById(tableName).rows;
// i starts from 1 to skip table header row
for (var i = 1; i < rows.length; i++) {
if (i < from || i > to)
rows[i].style.display = 'none';
else
rows[i].style.display = '';
}
}
this.showPage = function(pageNumber) {
if (! this.inited) {
alert("not inited");
return;
}
var oldPageAnchor = document.getElementById('pg'+this.currentPage);
oldPageAnchor.className = 'pg-normal';
this.currentPage = pageNumber;
var newPageAnchor = document.getElementById('pg'+this.currentPage);
newPageAnchor.className = 'pg-selected';
var from = (pageNumber - 1) * itemsPerPage + 1;
var to = from + itemsPerPage - 1;
this.showRecords(from, to);
}
this.prev = function() {
if (this.currentPage > 1)
this.showPage(this.currentPage - 1);
}
this.next = function() {
if (this.currentPage < this.pages) {
this.showPage(this.currentPage + 1);
}
}
this.init = function() {
var rows = document.getElementById(tableName).rows;
var records = (rows.length - 1);
this.pages = Math.ceil(records / itemsPerPage);
this.inited = true;
}
this.showPageNav = function(pagerName, positionId) {
if (! this.inited) {
alert("not inited");
return;
}
var element = document.getElementById(positionId);
var pagerHtml = '<span onclick="' + pagerName + '.prev();" class="pg-normal"> « Prev </span> ';
for (var page = 1; page <= this.pages; page++)
pagerHtml += '<span id="pg' + page + '" class="pg-normal" onclick="' + pagerName + '.showPage(' + page + ');">' + page + '</span> ';
pagerHtml += '<span onclick="'+pagerName+'.next();" class="pg-normal"> Next »</span>';
element.innerHTML = pagerHtml;
}
}
</script>
<style>
table { width:100%; font-size:14px; }
table tr { border-bottom:1px solid #333;}
table td {
margin: 1px;
padding: 2px;
text-align:center;
/*border-top:1px solid #333; */
}
table th{
font-size: 12px;
font-weight: bold;
color: #FFF;
background-color: #00345E;
margin: 2px;
padding: 2px;
}
table img { border: 1px solid #006; border-radius : 5px;}
.container{
width: 530px;
float: left;
/*margin: 50px 10px 10px;*/
padding: 20px;
background-color: white;
}
.page_navigation , .alt_page_navigation{
padding-bottom: 40px;
}
.page_navigation a, .alt_page_navigation a{
padding:3px 5px;
margin:2px;
color:white;
text-decoration:none;
float: left;
font-family: Tahoma;
font-size: 12px;
background-color:#2D64B6;
}
.active_page{
background-color:white !important;
color:black !important;
}
.content, .alt_content{
color: black;
}
.content li, .alt_content li, .content > p{
padding: 5px
}
.pg-normal {
color: #fff;
font-size: 15px;
cursor: pointer;
background: #2D64B6;
padding: 2px 4px 2px 4px;
}
.pg-selected {
color: #fff;
font-size: 15px;
background: #000000;
padding: 2px 4px 2px 4px;
}
</style>
</head>
<body>
<!--==============================header=================================-->
<div class="content_my">
<div class="grid_12">
<div align="center">
<h1 class="extra-wrap"><a href="#"><img src="../images/suraj-auto.png"></a></h1>
</div>
<div class="clear"></div>
<nav>
<ul class="sf-menu">
<li style="width:150px;" ><a href="welcome.php">Home</a></li>
<li style="width:200px;" class="current"><a href="#">Manage Images</a>
<ul>
<li><a href="add_images.php">Add Images</a></li>
<li><a href="view_images.php">View Images</a></li>
<li><a href="page_wise.php">View Page Wise</a></li>
</ul>
</li>
<li style="width:200px;"><a href="page_contents.php">Edit Page Contents</a></li>
<li style="width:180px;"><a href="change_password.php">Change Password</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
<div class="clear"></div>
</nav>
<!--==============================footer=================================-->
<footer class="wrapper top-8">
<div class="content_my">
<div class="grid_12 border-2"></div>
<div class="clear"></div>
<div class="grid_6" >
<h3>View Images: </h3>
<div style="color:#0C0;"><b><?php echo $msg; ?></b></div>
<div >
<table id="tablepaging" align="center" >
<thead>
<tr >
<th>Sl No</th>
<th>Image</th>
<th>Image Name</th>
<th>Page Name</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<?php if($query < 1) { echo "No Record Found.";} $i=1; while ($row = mysql_fetch_array($query)) { ?>
<tr class="<?php if($i%2 == 0) echo "even1"; else echo "odd1"; ?>" >
<td><?php echo $i; ?></td>
<td><img src="products/thumb/<?php echo $row['img_thumb']; ?>" /></td>
<td><?php echo $row['image_name']; ?></td>
<td><?php echo $row['page_name']; ?></td>
<td><a href="edit_images.php?id=<?php echo $row['image_id']; ?>"> Edit </a> </td>
<td><a href="view_images.php?delete=<?php echo $row['image_id']; ?>" onClick="return confirm('Are you sure you want to delete this image , click ok to confirm else cancel.')">Delete</a> </td>
</tr>
<?php $i++; } ?>
</tbody>
</table>
<div id="pageNavPosition" style="padding-top: 20px" align="center">
</div><br/><br/>
<script type="text/javascript"><!--
var pager = new Pager('tablepaging', 10);
pager.init();
pager.showPageNav('pager', 'pageNavPosition');
pager.showPage(1);
</script>
</div>
<div class="grid_12 border-2"></div>
<div class="clear"></div>
<div class="grid_6"><p class="top-1">Suraj Automobiles © 2013 : <a class="color-2" href="#">Privacy Policy</a><br />
<!-- Do not remove -->Design by <a class="color-2" href="http://www.visualcreations.in">Visual Creations</a><!-- end --></p>
</div>
</div>
</footer>
</div>
</div>
</body>
</html>