<!--<style type="text/css">
#event-icon{ background:url("../images/events-screen-icon.png");}
</style>-->
<script type="text/javascript">
function validate()
{
var delete_data=confirm("Do you really want to delete this row?");
if(delete_data==false)
{
return false;
}
else
{
return true;
}
}
</script>
</head>
<body>
<div class="wrap">
<div id="event-icon"></div>
<h2><?php echo '<img src="' . plugins_url( 'images/event1.png' , __FILE__ ) . '" > ';?>
CAST AND CREW DETAILS</h2>
<form name="form1" id="form1" method="post" action="" enctype="multipart/form-data">
<?php
global $wpdb;
$url = admin_url( 'admin.php?page=add-image', '' );
$url2 = admin_url('admin.php?page=cast_crew/cast_crew_table.php', '');
$table_name = $wpdb->prefix . "tblcast_crew";
//Pagination
$rowsPerPage = 2; //number of rows per page
$currentPage = ((isset($_GET['page_new']) && $_GET['page_new'] > 0) ? (int)$_GET['page_new'] : 1);
//limit=rowsperpage start=offset
$offset = ($currentPage-1)*$rowsPerPage;
$query="SELECT * FROM $table_name LIMIT ".$offset.",".$rowsPerPage;
$row=$wpdb->get_results($query);
//Get Admin Page parent
//$a=get_admin_page_parent();
//echo "<br/>"."Admin Page parent is :".$a."<br/>";
//Get Plugin URL
//$plugins_url = plugins_url();
//echo "<br/>"."Plugin URL : ".$plugins_url."<br/>";
//Get Admin URL
//$adminurl=get_admin_url();
//echo "<br/>"."Admin URL : ".$adminurl;
?>
<table width='600' border='1' class='widefat'>
<thead>
<tr>
<th>Id</th>
<th>Title</th>
<th>Photo</th>
<th>Description</th>
<th>Designation</th>
<th>Photo By</th>
<th>Delete</th>
<th>Update</th>
</tr>
</thead>
<tr>
<?php
foreach ( $row as $row1 )
{
// $upload_dir=wp_upload_dir();
$TARGET_PATH="/wp-content/uploads/mydir/";
//echo $TARGET_PATH.$row1->image;
$path=get_site_url().$TARGET_PATH;
//echo plugins_url('cast_crew/upload/');
$id=$row1->id;
?>
<td><?php echo $row1->id; ?></td>
<td><?php echo $row1->image_title; ?></td>
<td><img src="<?php echo $path.$row1->image; ?>" width="40" height="40"/></td>
<td><?php echo $row1->image_desc; ?></td>
<td><?php echo $row1->image_desig; ?></td>
<td><?php echo $row1->image_by; ?></td>
<td><a href="<?php echo $url2;?>&id=<?php echo $id; ?>" onClick="return validate();"><img src="<?php echo plugins_url('cast_crew/images/delete.jpeg') ?>" width="15" height="15"></a></td>
<!-- <td><a href="<?php echo $url2;?>&id=<?php echo $id; ?>" onClick="return validate();">Delete</a></td>
-->
<!-- <td><a href="<?php echo $url;?>&id=<?php echo $id;?>">Update</a></td>
-->
<td><a href="<?php echo $url;?>&id=<?php echo $id;?>"><img src="<?php echo plugins_url('cast_crew/images/edit.jpeg') ?>" width="25" height="25"></a></td>
</tr>
<input name='id' type='hidden' value='$id'/>
<?php
}
?>
</table>
<?php
//retrieve number of entries in a table
$results = $wpdb->get_results("SELECT id FROM $table_name");
$c=1;
$total= count($results);
//echo "Total rows".$total;
//echo "<br/>"."Rows per page".$rowsPerPage;
$total_pages = $total;
$totalPages = ceil($total_pages / $rowsPerPage);
?>
<br/><br/>
<!--echo "pages".$totalPages;-->
<?php
// page
//echo "Page no. ".$currentPage;
echo " "." ";
if($currentPage > 1) {
echo "<a href='$url2&page_new=" . ($currentPage - 1) . "'>Previous Page</a>";
}
echo " "." ";
echo $currentPage;
echo " "." ";
if($currentPage < $totalPages) {
echo "<a href='$url2&page_new=" . ($currentPage + 1) . "'>Next Page</a>";
}
if(isset($_GET['id']))
{
$id = $_GET["id"];
$table_name = $wpdb->prefix . "tblcast_crew";
$del_row=$wpdb->get_row("SELECT image FROM $table_name WHERE id = " . $id);
$image_name=$del_row->image;
$upload_dir = wp_upload_dir();
$TARGET_PATH=$upload_dir['basedir']."/"."mydir";
if($TARGET_PATH."/".$image_name)
{
$sql = "DELETE FROM " . $table_name . " WHERE id = " . $id;
$result = $wpdb->query($sql);
unlink($TARGET_PATH."/".$image_name);
}
else
{
echo "Image Not Found...!";
}
}
?>
</form>
</div>
</body>
</html>
#event-icon{ background:url("../images/events-screen-icon.png");}
</style>-->
<script type="text/javascript">
function validate()
{
var delete_data=confirm("Do you really want to delete this row?");
if(delete_data==false)
{
return false;
}
else
{
return true;
}
}
</script>
</head>
<body>
<div class="wrap">
<div id="event-icon"></div>
<h2><?php echo '<img src="' . plugins_url( 'images/event1.png' , __FILE__ ) . '" > ';?>
CAST AND CREW DETAILS</h2>
<form name="form1" id="form1" method="post" action="" enctype="multipart/form-data">
<?php
global $wpdb;
$url = admin_url( 'admin.php?page=add-image', '' );
$url2 = admin_url('admin.php?page=cast_crew/cast_crew_table.php', '');
$table_name = $wpdb->prefix . "tblcast_crew";
//Pagination
$rowsPerPage = 2; //number of rows per page
$currentPage = ((isset($_GET['page_new']) && $_GET['page_new'] > 0) ? (int)$_GET['page_new'] : 1);
//limit=rowsperpage start=offset
$offset = ($currentPage-1)*$rowsPerPage;
$query="SELECT * FROM $table_name LIMIT ".$offset.",".$rowsPerPage;
$row=$wpdb->get_results($query);
//Get Admin Page parent
//$a=get_admin_page_parent();
//echo "<br/>"."Admin Page parent is :".$a."<br/>";
//Get Plugin URL
//$plugins_url = plugins_url();
//echo "<br/>"."Plugin URL : ".$plugins_url."<br/>";
//Get Admin URL
//$adminurl=get_admin_url();
//echo "<br/>"."Admin URL : ".$adminurl;
?>
<table width='600' border='1' class='widefat'>
<thead>
<tr>
<th>Id</th>
<th>Title</th>
<th>Photo</th>
<th>Description</th>
<th>Designation</th>
<th>Photo By</th>
<th>Delete</th>
<th>Update</th>
</tr>
</thead>
<tr>
<?php
foreach ( $row as $row1 )
{
// $upload_dir=wp_upload_dir();
$TARGET_PATH="/wp-content/uploads/mydir/";
//echo $TARGET_PATH.$row1->image;
$path=get_site_url().$TARGET_PATH;
//echo plugins_url('cast_crew/upload/');
$id=$row1->id;
?>
<td><?php echo $row1->id; ?></td>
<td><?php echo $row1->image_title; ?></td>
<td><img src="<?php echo $path.$row1->image; ?>" width="40" height="40"/></td>
<td><?php echo $row1->image_desc; ?></td>
<td><?php echo $row1->image_desig; ?></td>
<td><?php echo $row1->image_by; ?></td>
<td><a href="<?php echo $url2;?>&id=<?php echo $id; ?>" onClick="return validate();"><img src="<?php echo plugins_url('cast_crew/images/delete.jpeg') ?>" width="15" height="15"></a></td>
<!-- <td><a href="<?php echo $url2;?>&id=<?php echo $id; ?>" onClick="return validate();">Delete</a></td>
-->
<!-- <td><a href="<?php echo $url;?>&id=<?php echo $id;?>">Update</a></td>
-->
<td><a href="<?php echo $url;?>&id=<?php echo $id;?>"><img src="<?php echo plugins_url('cast_crew/images/edit.jpeg') ?>" width="25" height="25"></a></td>
</tr>
<input name='id' type='hidden' value='$id'/>
<?php
}
?>
</table>
<?php
//retrieve number of entries in a table
$results = $wpdb->get_results("SELECT id FROM $table_name");
$c=1;
$total= count($results);
//echo "Total rows".$total;
//echo "<br/>"."Rows per page".$rowsPerPage;
$total_pages = $total;
$totalPages = ceil($total_pages / $rowsPerPage);
?>
<br/><br/>
<!--echo "pages".$totalPages;-->
<?php
// page
//echo "Page no. ".$currentPage;
echo " "." ";
if($currentPage > 1) {
echo "<a href='$url2&page_new=" . ($currentPage - 1) . "'>Previous Page</a>";
}
echo " "." ";
echo $currentPage;
echo " "." ";
if($currentPage < $totalPages) {
echo "<a href='$url2&page_new=" . ($currentPage + 1) . "'>Next Page</a>";
}
if(isset($_GET['id']))
{
$id = $_GET["id"];
$table_name = $wpdb->prefix . "tblcast_crew";
$del_row=$wpdb->get_row("SELECT image FROM $table_name WHERE id = " . $id);
$image_name=$del_row->image;
$upload_dir = wp_upload_dir();
$TARGET_PATH=$upload_dir['basedir']."/"."mydir";
if($TARGET_PATH."/".$image_name)
{
$sql = "DELETE FROM " . $table_name . " WHERE id = " . $id;
$result = $wpdb->query($sql);
unlink($TARGET_PATH."/".$image_name);
}
else
{
echo "Image Not Found...!";
}
}
?>
</form>
</div>
</body>
</html>