<?php
if(!isset($username)){
   exit; 
}
?>
<div style='width:1050px;height:755px;background:#fff;'>
<center>
<br>
<p style="font-size: 20px;text-align: center;color:#676767;">分享传播推广列表</p>
<br/>
<table width="1000px" align="center" cellspacing="0" border="0" style="color:#676767;background: #fff;">
<tr style="background: #009999;height:30px;color:#fff;"><th>序号</th><th>推广标题</th><th>推广金额</th><th>推广余额</th><th>推广单价</th><th>推广数量</th><th>剩余数量</th><th>投放区域</th><th>是否结束</th><th>发布者</th><th>发布时间</th><th>开始赚钱</th></tr>
<?php


$cha_uid="select id from user where username='{$username}'";
$cha_rst=mysql_query($cha_uid);
$cha_row=mysql_fetch_assoc($cha_rst);
$length=10;
$totsql="select count(*) from user_renwu";
$totrst=mysql_query($totsql);
$totarr=mysql_fetch_row($totrst);
//总页数
$totpage=ceil($totarr[0]/$length);
//当前页
$pagenum=@$_GET['page']?@$_GET['page']:1;
//限制最大页数
if($pagenum>=$totpage){$pagenum=$totpage;}
//offset算法
$offset=($pagenum-1)*$length;
$zhuansql="select * from user_renwu order by id desc limit {$offset},{$length} ";
$zhuanrst=mysql_query($zhuansql);

//获取所有数据
$i=0;
while($zhuanrow=@mysql_fetch_assoc($zhuanrst)){
    $i++;
    echo "<tr align='center' style='height:50px;background:#fff;'>"; 
    echo "<td>";
    echo "<span style='padding:2px 5px 2px 5px;background:#ccc;'>{$i}</span>";
    echo "</td>";
    echo "<td>";
    echo mb_substr($zhuanrow['biaoti'],0,7,"utf-8").'...';
    echo "</td>";
    echo "<td>";
    echo $zhuanrow['jiner']."元";
    echo "</td>";
    echo "<td>";
    echo $zhuanrow['yuer']."元";
    echo "</td>";
    echo "<td>";
    echo $zhuanrow['meijian']."元";
    echo "</td>";
    echo "<td>";
    echo $zhuanrow['jianshu']."个";
    echo "</td>";
    echo "<td>";
    echo $zhuanrow['shengyu']."个";
    echo "</td>";
    echo "<td>";
    echo $zhuanrow['jilian'];
    echo "</td>";
    echo "<td>";
    if($zhuanrow['jieshu']){
        echo "<span style='color:red;'>结束</span>";
    }else{
        echo "<span style='color:#009999;'>正常</span>";
    }
    echo "</td>";
    echo "<td>";
    echo $zhuanrow['username'];
    echo "</td>";
    echo "<td>";
    echo date("Y/m/d",$zhuanrow['time']);
    echo "</td>";
    echo "<td>";
    echo "<a class='lingqu' href='renwu_xiangqing.php?aid={$zhuanrow['id']}&uid={$cha_row['id']}' style='color:#111;padding:2px 5px 2px 5px;' target='_brank'><img style='border:0px;' src='../image/lqtg.png'></a>";
    echo "</td>";
    echo "</tr>";
    
}
echo "</table>";
//计算上一页和下一页
$prevpage=$pagenum-1;
$nextpage=$pagenum+1;
echo "<br/>";
echo "<p>";
echo "<a href='user_index.php?page=1'>首页</a>&nbsp;<a href='user_index.php?page={$prevpage}'>&lt;上一页</a>";
echo "&nbsp;<a style='color:#009999;' href='user_index.php?page={$pagenum}'>{$pagenum}</a>&nbsp;/&nbsp;<span>{$totpage}</span>";
echo "<a href='user_index.php?page={$nextpage}'>&nbsp;下一页&gt;</a>&nbsp;<a href='user_index.php?page={$totpage}'>尾页</a>";
echo "</p>";
@mysql_free_result($zhuanrst);
mysql_free_result($totrst);
mysql_close($con);
?>
</center>
</div>
