21,887
社区成员
发帖
与我相关
我的任务
分享
<?php
include "../../conf/configandconn.php";
require_once '../../comm/comm.func.php';
$sql="SELECT p.cid,p.date,p.product_id,p.product_content,p.product_level,p.product_name,p.product_price,p.status,c.catalog_name,c.id FROM product AS p JOIN catalog c ON p.cid=c.id";
$totalrows=getresultnum($sql);
$pagesize=2;
$totalpage=ceil($totalrows/$pagesize);
$page = isset($_REQUEST['page'])?(int)$_REQUEST['page']:1;
if($page<1||$page==null||!is_numeric($page)){
$page=1;
}
if($page>=$totalpage)$page=$totalpage;
$offset=($page-1)*$pagesize;
$sql="SELECT p.cid,p.date,p.product_id,p.product_content,p.product_level,p.product_name,p.product_price,p.status,c.catalog_name,c.id FROM product AS p JOIN catalog c ON p.cid=c.id LIMIT {$offset},{$pagesize}";
$res=mysql_query($sql);
if($res&&mysql_num_rows($res)){
while($row =mysql_fetch_assoc($res)){
$data[] = $row;
}
}else{
$data = array();
}
/* print_r($data);
exit; */
function showpage($page,$totalpage,$sep=" "){
$p="";
$url = $_SERVER ['PHP_SELF'];
$index = ($page == 1) ? "首页" : "<a href='{$url}?page=1'>首页</a>";
$last = ($page == $totalpage) ? "尾页" : "<a href='{$url}?page={$totalpage}'>尾页</a>";
$prev = ($page == 1) ? "上一页" : "<a href='{$url}?page=".($page-1)."'>上一页</a>";
$next = ($page == $totalpage) ? "下一页" : "<a href='{$url}?page=".($page+1)."'>下一页</a>";
$str = "总共{$totalpage}页/当前是第{$page}页";
for($i=1;$i<=$totalpage;$i++){
if($page==$i){
$p.="[{$i}]";
}else{
$p.="<a href='{$url}?page={$i}'>[{$i}]</a>";
}
}
$pagestr=$str.$sep.$index.$sep.$prev.$sep.$p.$sep.$next.$sep.$last;
return $pagestr;
}
?>
<html>
<head>
<meta charset="utf-8">
<title>-.-</title>
<link rel="stylesheet" href="../../css/backstage.css">
<link rel="stylesheet" href="../../css/jquery-ui-1.10.4.custom.css" />
<script src="../../js/jquery-1.10.2.js"></script>
<script src="../../js/jquery-ui-1.10.4.custom.js"></script>
<script src="../../js/jquery-ui-1.10.4.custom.min.js"></script>
</head>
<body>
<div id="showDetail" style="display:none;">
</div>
<div class="details">
<div class="details_operation clearfix">
<div class="bui_select">
<input type="button" value="添 加" class="add" onclick="addPro()">
</div>
<div class="fr">
<div class="text">
<span>商品名称:</span>
<div class="bui_select">
<select name="" id="" class="select">
<option value="1">测试内容</option>
<option value="1">测试内容</option>
<option value="1">测试内容</option>
</select>
</div>
</div>
<div class="text">
<span>上架时间:</span>
<div class="bui_select">
<select name="" id="" class="select">
<option value="1">测试内容</option>
<option value="1">测试内容</option>
<option value="1">测试内容</option>
</select>
</div>
</div>
<div class="text">
<span>搜索</span>
<input type="text" value="" class="search">
</div>
</div>
</div>
<!--表格-->
<table class="table" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th width="10%">编号</th>
<th width="20%">商品名称</th>
<th width="20%">商品分类</th>
<th width="20%">是否上架</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php $i=1;foreach($data as $val): ?>
<tr>
<!--这里的id和for里面的c1 需要循环出来-->
<td><input type="checkbox" id="c1" class="check" value=<?php echo $val['product_id'];?>><label for="c1" class="label"><?php echo $i;?></label></td>
<td><?php echo $val['product_name']; ?></td>
<td><?php echo $val['catalog_name'];?></td>
<td>
<?php
$show=($val['status']==1)?"上架":"下架";
echo $show;
?>
</td>
<td align="center">
<input type="button" value="详情" class="btn" onclick="showDetail(<?php echo $val['product_id'];?>,'<?php echo $val['product_name'];?>')"><input type="button" value="修改" class="btn"><input type="button" value="删除" class="btn">
<div id="showDetail<?php echo $val['product_id'];?>" style="display:none;">
<table class="table" cellspacing="0" cellpadding="0">
<tr>
<td width="20%" align="right">商品名称</td>
<td><?php echo $val['product_name'];?></td>
</tr>
<tr>
<td width="20%" align="right">商品类别</td>
<td><?php echo $val['catalog_name'];?></td>
</tr>
<tr>
<td width="20%" align="right">商品货号</td>
<td><?php echo $val['product_id'];?></td>
</tr>
<tr>
<td width="20%" align="right">商品数量</td>
<td><?php echo $row['pNum'];?></td>
</tr>
<tr>
<td width="20%" align="right">商品价格</td>
<td><?php echo $val['product_price'];?></td>
</tr>
<tr>
<td width="20%" align="right">幕课网价格</td>
<td><?php echo $row['iPrice'];?></td>
</tr>
<tr>
<td width="20%" align="right">商品图片</td>
<td>
<?php
$images=getallimgbyproid($val['product_id']);
print_r($images);
foreach($images as $img){
echo "<img src='../../img/upload/proimg/img/{$img['path']}' alt=''/> ";
}
?>
</td>
</tr>
<tr>
<td width="20%" align="right">是否上架</td>
<td>
<?php
$show=($row['isShow']==1)?"上架":"下架";
echo $show;
?>
</td>
</tr>
<tr>
<td width="20%" align="right">是否热卖</td>
<td>
<?php
$hot=($row['isShow']==1)?"热卖":"促销";
echo $hot;
?>
</td>
</tr>
</table>
<span style="display:block;width:80%; ">
商品描述<br/>
<?php echo $val['product_content'];?>
</span>
</div>
</td>
</tr>
<?php $i++; endforeach;?>
<td colspan="7"><?php echo showpage($page,$totalpage);?></td>
</tbody>
</table>
</div>
<script type="text/javascript">
function showDetail(id,t){
$("#showDetail"+id).dialog({
height:"auto",
width: "auto",
position: {my: "center", at: "center", collision:"fit"},
modal:false,//是否模式对话框
draggable:true,//是否允许拖拽
resizable:true,//是否允许拖动
title:"商品名称:"+t,//对话框标题
show:"slide",
hide:"explode"
});
}
function addPro(){
window.location='addPro.php';
}
</script>
</body>
</html>
require_once '../../comm/comm.func.php';的内容为
[code=php]function getallimgbyproid($product_id){
$sql="select path from img where product_id={$product_id}";
$result = mysql_query($sql);
$arr=mysql_fetch_array($result);
return $arr;
}