<?php
include('admin_access.php');
$edition = $_GET['edition'];
$description = $_GET['description'];
$category_id = $_GET['category_id'];
$country_id = $_GET['country_id'];
$city_id = $_GET['city_id'];
$year = $_GET['year'];
$firstdate = $_GET['firstdate'];
$lastdate = $_GET['lastdate'];
$status_id = $_GET['status_id'];
$source = $_GET['source'];
$remark = $_GET['remark'];
$sort_field = $_GET['sort_field'];
$sort_type = $_GET['sort_type'];
$str_page = $_GET['str_page'];
include('connect.php');
if ($sort_field == '') {
$sort_field = 'category.category_name,country.country_name,city.city_name';
}
if ($sort_type == '') {
$sort_type = 'ASC';
}
if ($sort_field == 'country.country_name') {
$sort_next = 'city.city_name ASC , item.date_acq ASC';
} else if ($sort_field == 'city.city_name') {
$sort_next = 'item.date_acq';
} else if ($sort_field == 'item.date_acq') {
$sort_next = 'country.country_name ASC, city.city_name ASC';
} else {
$sort_next = 'country.country_name ASC, city.city_name ASC, item.date_acq';
}
if ($edition != '') {
$sql_edition = "AND item.edition LIKE '$edition'";
}
if ($description != '') {
$sql_description = "AND item.description LIKE '$description'";
}
if ($category_id != '') {
$sql_category_id = "AND category.category_id = '$category_id'";
}
if ($country_id != '') {
$sql_country_id = "AND country.country_id = '$country_id'";
}
if ($city_id != '') {
$sql_city_id = "AND city.city_id = '$city_id'";
}
if ($year != '') {
$sql_year = "AND item.year = '$year'";
}
if ($firstdate != '') {
if ($lastdate == '') {
$sql_date = "AND item.date_acq = '$firstdate'";
} else {
$sql_date = "AND item.date_acq >= '$firstdate' AND item.date_acq <= '$lastdate'";
}
}
if ($status_id != '') {
$sql_status_id = "AND status.status_id = '$status_id'";
}
if ($source != '') {
$sql_source = "AND item.sorce LIKE '$source'";
}
if ($remark != '') {
$sql_remark = "AND item.remark LIKE '$remark'";
}
$sql = "SELECT item.*,category.*,country.*,city.*,status.*
FROM (((item LEFT JOIN category ON item.category_id = category.category_id)
LEFT JOIN country ON item.country_id = country.country_id)
LEFT JOIN city ON item.city_id = city.city_id)
LEFT JOIN status ON item.status_id = status.status_id
WHERE item.id != ''
$sql_edition
$sql_description
$sql_category_id
$sql_country_id
$sql_city_id
$sql_year
$sql_date
$sql_status_id
$sql_source
$sql_remark";
$query = mysql_query($sql) or die (" error 98 $sql ");
$record = mysql_num_rows($query);
$str_page = $_GET['str_page'];
$per_page = 20;
if ($record < $per_page) {
$show_page_record = $record;
} else {
$show_page_record = $per_page;
}
if ($record <= $per_page) {
$num_pages = 1;
} else if (($record % $per_page) == 0) {
$num_pages = ($record/$per_page);
} else {
$num_pages = ($record/$per_page) + 1;
$num_pages = (int)$num_pages;
}
if ($str_page == '') {
$page = 1;
} else if ($str_page < 1) {
$page = 1;
} else if ($str_page > $num_pages) {
$page = $num_pages;
} else {
$page = $str_page;
}
$prev_page = $page - 1;
$next_page = $page + 1;
if ($prev_page < 1) {
$prev_page = 1;
}
if ($next_page > $num_pages) {
$next_page = $num_pages;
}
$page_start = (($per_page * $page) - $per_page);
$sql.= "ORDER BY $sort_field $sort_type, $sort_next LIMIT $page_start , $per_page";
$query = mysql_query($sql) or die (" error 138 : $sql ");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>:::EDIT ITEMS:::</title>
<style TYPE="text/css">
<!--
a
{
color:#000080;
font-family:verdana;
text-decoration:none;
font-size:12px
}
a:active
{
color:red;
}
a:hover
{
color:#FF0000;
text-decoration:none;
cursor:crosshair;
}
table
{
font-family:verdana;
}
.td
{
font-family:verdana;
font-size:10px;
font-weight:lighter;
text-align:center;
}
.td1
{
font-family:verdana;
font-size:10px;
font-weight:lighter;
text-align:center;
color:#FFF;
}
.title
{
font-family:verdana;
font-size:12px;
font-weight:bold;
text-align:center;
}
.header
{
font-family:Tahoma;
font-size:17px;
font-weight:bold;
text-align:left;
}
.b
{
font-color:#FF0000;
font-family:verdana;
font-size:12px;
}
body
{
background-color:#0c3f00;
background-size:cover;
margin-top: 0px;
}
.searchspan {
font-family:Tahoma, Geneva, sans-serif;
font-size:12px;
text-align:right;
float:right;
margin-right:15px;
margin-top:3px;
}
-->
</STYLE>
</head>
<script language="javascript">
function conf_delete() {
if (confirm('Delete ?') == true) {
return true
} else {
return false
}
}
</script>
<body>
<?php
include('connect.php');
?>
<table width="900" border="1" cellspacing="0" cellpadding="5" style="border-collapse:collapse" bordercolor="#999999" align="center" bgcolor="#FFFFFF">
<tr>
<td colspan="15" style="background-image:url(image/sbux-header.jpg); background-size:cover;" height="311">
</td>
</tr>
<tr>
<td colspan="15" bgcolor="#FFFFFF">
<?php
include('menu.php');
?>
</td>
</tr>
<tr>
<td colspan="15" bgcolor="#D6D6D6" class="header">My Sbux Collections (Admin) <span style="font-size:12px; color:#666">(Showing <strong><?php echo $show_page_record;?></strong> of <strong><?php echo $record;?></strong> Records. Page <strong><?php echo $page;?></strong> of <strong><?php echo $num_pages;?></strong> Pages.) </span> <span class="searchspan"><a href="item_search.php?search_mode=1">Search</a></span></td>
</tr>
<tr>
<td colspan="15"><a href="item_add.php">New</a></td>
</tr>
<tr>
<td class="title" bgcolor="#D6D6D6"><a href="item_admin.php?edition=<?php echo $edition;?>&description=<?php echo $description;?>&category_id=<?php echo $category_id;?>&country_id=<?php echo $country_id;?>&city_id=<?php echo $city_id;?>&year=<?php echo $year;?>&firstdate=<?php echo $firstdate;?>&lastdate=<?php echo $lastdate;?>&status_id=<?php echo $status_id;?>&source=<?php echo $source;?>&remark=<?php echo $remark;?>&sort_field=item.id&sort_type=<?php if ($sort_field == 'item.id' && $sort_type == 'ASC') { echo 'DESC'; } else { echo 'ASC'; }?>">Mug Details</a><?php if ($sort_field == 'item.id') { ?> <img src="<?php if ($sort_type == 'DESC') { echo "image/up.png"; } else { echo "image/down.png"; } ?>" width="12" height="12" border="0" /><?php } ?></td>
<td class="title" bgcolor="#D6D6D6">Edit</td>
<td class="title" bgcolor="#D6D6D6">Delete</td>
<td class="title" bgcolor="#D6D6D6">No.</td>
<td class="title" bgcolor="#D6D6D6">Picture</td>
<td class="title" bgcolor="#D6D6D6"><a href="item_admin.php?edition=<?php echo $edition;?>&description=<?php echo $description;?>&category_id=<?php echo $category_id;?>&country_id=<?php echo $country_id;?>&city_id=<?php echo $city_id;?>&year=<?php echo $year;?>&firstdate=<?php echo $firstdate;?>&lastdate=<?php echo $lastdate;?>&status_id=<?php echo $status_id;?>&source=<?php echo $source;?>&remark=<?php echo $remark;?>&sort_field=item.edition&sort_type=<?php if ($sort_field == 'item.edition' && $sort_type == 'ASC') { echo 'DESC'; } else { echo 'ASC'; }?>">Edition</a><?php if ($sort_field == 'item.edition') { ?> <img src="<?php if ($sort_type == 'DESC') { echo "image/up.png"; } else { echo "image/down.png"; } ?>" width="12" height="12" border="0" /><?php } ?></td>
<td class="title" bgcolor="#D6D6D6"><a href="item_admin.php?edition=<?php echo $edition;?>&description=<?php echo $description;?>&category_id=<?php echo $category_id;?>&country_id=<?php echo $country_id;?>&city_id=<?php echo $city_id;?>&year=<?php echo $year;?>&firstdate=<?php echo $firstdate;?>&lastdate=<?php echo $lastdate;?>&status_id=<?php echo $status_id;?>&source=<?php echo $source;?>&remark=<?php echo $remark;?>&sort_field=item.description&sort_type=<?php if ($sort_field == 'item.description' && $sort_type == 'ASC') { echo 'DESC'; } else { echo 'ASC'; }?>">Description</a><?php if ($sort_field == 'item.description') { ?> <img src="<?php if ($sort_type == 'DESC') { echo "image/up.png"; } else { echo "image/down.png"; } ?>" width="12" height="12" border="0" /><?php } ?></td>
<td class="title" bgcolor="#D6D6D6"><a href="item_admin.php?edition=<?php echo $edition;?>&description=<?php echo $description;?>&category_id=<?php echo $category_id;?>&country_id=<?php echo $country_id;?>&city_id=<?php echo $city_id;?>&year=<?php echo $year;?>&firstdate=<?php echo $firstdate;?>&lastdate=<?php echo $lastdate;?>&status_id=<?php echo $status_id;?>&source=<?php echo $source;?>&remark=<?php echo $remark;?>&sort_field=category.category_name&sort_type=<?php if ($sort_field == 'category.category_name' && $sort_type == 'ASC') { echo 'DESC'; } else { echo 'ASC'; }?>">Category</a><?php if ($sort_field == 'category.category_name') { ?> <img src="<?php if ($sort_type == 'DESC') { echo "image/up.png"; } else { echo "image/down.png"; } ?>" width="12" height="12" border="0" /><?php } ?></td>
<td class="title" bgcolor="#D6D6D6"><a href="item_admin.php?edition=<?php echo $edition;?>&description=<?php echo $description;?>&category_id=<?php echo $category_id;?>&country_id=<?php echo $country_id;?>&city_id=<?php echo $city_id;?>&year=<?php echo $year;?>&firstdate=<?php echo $firstdate;?>&lastdate=<?php echo $lastdate;?>&status_id=<?php echo $status_id;?>&source=<?php echo $source;?>&remark=<?php echo $remark;?>&sort_field=country.country_name&sort_type=<?php if ($sort_field == 'country.country_name' && $sort_type == 'ASC') { echo 'DESC'; } else { echo 'ASC'; }?>">Country</a><?php if ($sort_field == 'country.country_name') { ?> <img src="<?php if ($sort_type == 'DESC') { echo "image/up.png"; } else { echo "image/down.png"; } ?>" width="12" height="12" border="0" /><?php } ?></td>
<td class="title" bgcolor="#D6D6D6"><a href="item_admin.php?edition=<?php echo $edition;?>&description=<?php echo $description;?>&category_id=<?php echo $category_id;?>&country_id=<?php echo $country_id;?>&city_id=<?php echo $city_id;?>&year=<?php echo $year;?>&firstdate=<?php echo $firstdate;?>&lastdate=<?php echo $lastdate;?>&status_id=<?php echo $status_id;?>&source=<?php echo $source;?>&remark=<?php echo $remark;?>&sort_field=city.city_name&sort_type=<?php if ($sort_field == 'city.city_name' && $sort_type == 'ASC') { echo 'DESC'; } else { echo 'ASC'; }?>">City</a><?php if ($sort_field == 'city.city_name') { ?> <img src="<?php if ($sort_type == 'DESC') { echo "image/up.png"; } else { echo "image/down.png"; } ?>" width="12" height="12" border="0" /><?php } ?></td>
<td class="title" bgcolor="#D6D6D6"><a href="item_admin.php?edition=<?php echo $edition;?>&description=<?php echo $description;?>&category_id=<?php echo $category_id;?>&country_id=<?php echo $country_id;?>&city_id=<?php echo $city_id;?>&year=<?php echo $year;?>&firstdate=<?php echo $firstdate;?>&lastdate=<?php echo $lastdate;?>&status_id=<?php echo $status_id;?>&source=<?php echo $source;?>&remark=<?php echo $remark;?>&sort_field=item.year&sort_type=<?php if ($sort_field == 'item.year' && $sort_type == 'ASC') { echo 'DESC'; } else { echo 'ASC'; }?>">Year</a><?php if ($sort_field == 'item.year') { ?> <img src="<?php if ($sort_type == 'DESC') { echo "image/up.png"; } else { echo "image/down.png"; } ?>" width="12" height="12" border="0" /><?php } ?></td>
<td class="title" bgcolor="#D6D6D6"><a href="item_admin.php?edition=<?php echo $edition;?>&description=<?php echo $description;?>&category_id=<?php echo $category_id;?>&country_id=<?php echo $country_id;?>&city_id=<?php echo $city_id;?>&year=<?php echo $year;?>&firstdate=<?php echo $firstdate;?>&lastdate=<?php echo $lastdate;?>&status_id=<?php echo $status_id;?>&source=<?php echo $source;?>&remark=<?php echo $remark;?>&sort_field=item.date_acq&sort_type=<?php if ($sort_field == 'item.date_acq' && $sort_type == 'ASC') { echo 'DESC'; } else { echo 'ASC'; }?>">Date Acquired</a><?php if ($sort_field == 'item.date_acq') { ?> <img src="<?php if ($sort_type == 'DESC') { echo "image/up.png"; } else { echo "image/down.png"; } ?>" width="12" height="12" border="0" /><?php } ?></td>
<td class="title" bgcolor="#D6D6D6"><a href="item_admin.php?edition=<?php echo $edition;?>&description=<?php echo $description;?>&category_id=<?php echo $category_id;?>&country_id=<?php echo $country_id;?>&city_id=<?php echo $city_id;?>&year=<?php echo $year;?>&firstdate=<?php echo $firstdate;?>&lastdate=<?php echo $lastdate;?>&status_id=<?php echo $status_id;?>&source=<?php echo $source;?>&remark=<?php echo $remark;?>&sort_field=status.status_name&sort_type=<?php if ($sort_field == 'status.status_name' && $sort_type == 'ASC') { echo 'DESC'; } else { echo 'ASC'; }?>">Status</a><?php if ($sort_field == 'status.status_name') { ?> <img src="<?php if ($sort_type == 'DESC') { echo "image/up.png"; } else { echo "image/down.png"; } ?>" width="12" height="12" border="0" /><?php } ?></td>
<td class="title" bgcolor="#D6D6D6"><a href="item_admin.php?edition=<?php echo $edition;?>&description=<?php echo $description;?>&category_id=<?php echo $category_id;?>&country_id=<?php echo $country_id;?>&city_id=<?php echo $city_id;?>&year=<?php echo $year;?>&firstdate=<?php echo $firstdate;?>&lastdate=<?php echo $lastdate;?>&status_id=<?php echo $status_id;?>&source=<?php echo $source;?>&remark=<?php echo $remark;?>&sort_field=item.sorce&sort_type=<?php if ($sort_field == 'item.sorce' && $sort_type == 'ASC') { echo 'DESC'; } else { echo 'ASC'; }?>">Source</a><?php if ($sort_field == 'item.sorce') { ?> <img src="<?php if ($sort_type == 'DESC') { echo "image/up.png"; } else { echo "image/down.png"; } ?>" width="12" height="12" border="0" /><?php } ?></td>
<td class="title" bgcolor="#D6D6D6"><a href="item_admin.php?edition=<?php echo $edition;?>&description=<?php echo $description;?>&category_id=<?php echo $category_id;?>&country_id=<?php echo $country_id;?>&city_id=<?php echo $city_id;?>&year=<?php echo $year;?>&firstdate=<?php echo $firstdate;?>&lastdate=<?php echo $lastdate;?>&status_id=<?php echo $status_id;?>&source=<?php echo $source;?>&remark=<?php echo $remark;?>&sort_field=item.remark&sort_type=<?php if ($sort_field == 'item.remark' && $sort_type == 'ASC') { echo 'DESC'; } else { echo 'ASC'; }?>">Remark</a><?php if ($sort_field == 'item.remark') { ?> <img src="<?php if ($sort_type == 'DESC') { echo "image/up.png"; } else { echo "image/down.png"; } ?>" width="12" height="12" border="0" /><?php } ?></td>
</tr>
<?php
$no = $page_start;
while ($result = mysql_fetch_array($query)) {
$no++;
if ($bgcolor == "#FFFFFF") {
$bgcolor = "#CCCCCC";
} else {
$bgcolor = "#FFFFFF";
}
?>
<tr bgcolor="<?php echo $bgcolor;?>">
<td class="td"><a href="item_show_detail.php?id=<?php echo $result['id'];?>">Details</a></td>
<td class="td"><a href="item_edit.php?id=<?php echo $result['id']?>">Edit</a></td>
<td class="td"><a href="item_check.php?action=delete&id=<?php echo $result['id'];?>" onclick="return conf_delete();">Delete</a></td>
<td class="td"><?php echo $no;?></td>
<td class="td"><img src="picture/<?=$result["picture"];?>" width="125" height="100"></td>
<td class="td"><?php echo $result['edition'];?></td>
<td class="td"><?php echo $result['description'];?></td>
<td class="td"><?php echo $result['category_name'];?></td>
<td class="td"><?php echo $result['country_name'];?></td>
<td class="td"><?php echo $result['city_name'];?></td>
<td class="td"><?php echo $result['year'];?></td>
<td class="td"><?php echo $result['date_acq'];?></td>
<td class="td" <?php if ($result['status_id'] == '1') { echo "bgcolor=\"#FFFFCC\""; } else if ($result['status_id'] == '2') { echo "bgcolor=\"#FFCC99\""; } ?>><?php echo $result['status_name'];?></td>
<td class="td"><?php echo $result['sorce'];?></td>
<td class="td"><?php echo $result['remark'];?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="15" bgcolor="#666666" class="td1">
<a href="item_admin.php?str_page=1&edition=<?php echo $edition;?>&description=<?php echo $description;?>&category_id=<?php echo $category_id;?>&country_id=<?php echo $country_id;?>&city_id=<?php echo $city_id;?>&year=<?php echo $year;?>&firstdate=<?php echo $firstdate;?>&lastdate=<?php echo $lastdate;?>&status_id=<?php echo $status_id;?>&source=<?php echo $source;?>&remark=<?php echo $remark;?>&sort_field=<?php echo $sort_field;?>&sort_type=<?php echo $sort_type;?>"><<First</a>
<a href="item_admin.php?str_page=<?php echo $prev_page;?>&edition=<?php echo $edition;?>&description=<?php echo $description;?>&category_id=<?php echo $category_id;?>&country_id=<?php echo $country_id;?>&city_id=<?php echo $city_id;?>&year=<?php echo $year;?>&firstdate=<?php echo $firstdate;?>&lastdate=<?php echo $lastdate;?>&status_id=<?php echo $status_id;?>&source=<?php echo $source;?>&remark=<?php echo $remark;?>&sort_field=<?php echo $sort_field;?>&sort_type=<?php echo $sort_type;?>"><Prev</a>
<?php
if ($str_page_start <= 0) {
$str_page_start = 1;
}
$str_page_stop = $str_page_start + 8;
if ($str_page_stop > $num_pages) {
$str_page_stop = $num_pages;
}
for ($i = $str_page_start; $i <= $str_page_stop; $i++) {
?>
<a href="item_admin.php?str_page=<?php echo $i;?>&edition=<?php echo $edition;?>&description=<?php echo $description;?>&category_id=<?php echo $category_id;?>&country_id=<?php echo $country_id;?>&city_id=<?php echo $city_id;?>&year=<?php echo $year;?>&firstdate=<?php echo $firstdate;?>&lastdate=<?php echo $lastdate;?>&status_id=<?php echo $status_id;?>&source=<?php echo $source;?>&remark=<?php echo $remark;?>&sort_field=<?php echo $sort_field;?>&sort_type=<?php echo $sort_type;?>" <?php if ($i==$page) { echo "style=\"font-weight:bold; color:#C04;\"";}?>>[<?php echo $i;?>]</a>
<?php
}
?>
<a href="item_admin.php?str_page=<?php echo $next_page;?>&edition=<?php echo $edition;?>&description=<?php echo $description;?>&category_id=<?php echo $category_id;?>&country_id=<?php echo $country_id;?>&city_id=<?php echo $city_id;?>&year=<?php echo $year;?>&firstdate=<?php echo $firstdate;?>&lastdate=<?php echo $lastdate;?>&status_id=<?php echo $status_id;?>&source=<?php echo $source;?>&remark=<?php echo $remark;?>&sort_field=<?php echo $sort_field;?>&sort_type=<?php echo $sort_type;?>">Next>></a>
<a href="item_admin.php?str_page=<?php echo $num_pages;?>&edition=<?php echo $edition;?>&description=<?php echo $description;?>&category_id=<?php echo $category_id;?>&country_id=<?php echo $country_id;?>&city_id=<?php echo $city_id;?>&year=<?php echo $year;?>&firstdate=<?php echo $firstdate;?>&lastdate=<?php echo $lastdate;?>&status_id=<?php echo $status_id;?>&source=<?php echo $source;?>&remark=<?php echo $remark;?>&sort_field=<?php echo $sort_field;?>&sort_type=<?php echo $sort_type;?>">Last>></a>
</td>
</tr>
<tr>
<td colspan="15" bgcolor="#666666" class="td1">
STARBUCKS MUGS COLLECTION ©2012
</td>
</tr>
</table>
</body>
</html>
Select all Open in new window
Dear EE experts,
Hi! Please see the attached embed code for the script of our item_admin page, we would like to ask for tech support on how to resolve the problem that, it stops to Page 9. In whereas, we uploaded 204 items already, so it should be around 11 pages by this time. But, it is still @ Page 9.
Thank you in advance & hope to hear soon...
We need to insure a lot of things, try to change the query like this:
Open in new window
And tell us what happen.