2个回答
展开全部
楼上的光有上页和下页,我来做个【首页】【上页】【下页】【末页】的。
<?php
$result_num1 = mysql_query("SELECT * FROM article");
$num1 = mysql_num_rows($result_num1);
$pagesize1 = 10;
$start1 = $_GET['start1'];
$flag1 = $_GET['flag1'];
//判断$start1是否有值
if ($start1 == null) {
$start1 = 0;
}
//判断完毕
//判断$flag1是否有值
if ($flag1 == null) {
$flag1 = 0;
}
//判断完毕
//判断标志位以确定$start1的值
if ($flag1 == 1 and $start1+$pagesize1 < $num1){
$start1 = $start1+$pagesize1;
}
if ($flag1 == 2 and $start1+$pagesize1 > 0){
$start1 = $start1-$pagesize1;
}
//判断完毕
$query_product_type = "SELECT art_title FROM article limit $start1, $pagesize1";
$result_product_type = mysql_query($query_product_type) or die("Query failed : " . mysql_error());
print ("<table width='100%'>
<tr>
<td valign='top' height = '188'>
<table width='100%'>");
while ($line_product = mysql_fetch_array($result_product_type, MYSQL_ASSOC)) {
print ("<tr>");
foreach ($line_product as $col_value_product_type) {
$result_product = mysql_query ("SELECT * FROM article WHERE art_title ='$col_value_product_type'");
$click_product = mysql_fetch_array($result_product) ;
print ("<td width='5%'><img border='0' src='../images/kind_list1.GIF' width='9' height='11'></td>");
print ("<td width='95%'><a href='view_article.php?art_title=$click_product[0]' target='view_article'><span style='font-size:
9pt'>$click_product[0]</span></a></td>");
}
print ("</tr>");
}
print ("</table>
</td></tr>");
//最后一页START标识
if (($num1 % $pagesize1) != 0){
$lastpage1 = $num1 - ($num1 % $pagesize1);
}else{
$lastpage1 = $num1 - $pagesize1;
}
//代码结束
//判断页数以及当前页代码
$pagenum1 = ceil($num1 / $pagesize1);
if ($start1 == 0){
$nowpage1 = 1;
}else{
$nowpage1 = ($start1 / $pagesize1) + 1;
}
//判断结束
print ("<tr>
<td><hr color='#314DA5' size='1' noshade style='border-style: dotted; border-width: 1px; padding: 0'></td>
</tr>
<tr>
<td><p align='center'><span style='font-size: 9pt'>第<font color = '#FF0000'><b>$nowpage1</b></font>页 | 共<font color =
'#FF0000'><b>$pagenum1</b></font>页 | 共<font color = '#FF0000'><b>$num1</b></font>条记录</span></td>
</tr>
<tr>
<td><p align='center'>");
//分页显示判断部分
if ($start1 == 0 and $pagesize1 < $num1){
print ("<span style='font-size: 9pt'>【首页】【上页】<a href ='page_baidu.php?flag1=1&start1=$start1'>【下页】</a><a href ='page_baidu.php?start1=$lastpage1'>【末页】</a></span>");
}elseif ($start1 >= $num1-$pagesize1 and $pagesize1 < $num1){
print ("<span style='font-size: 9pt'><a href ='page_baidu.php?start1=0'>【首页】</a><a href ='page_baidu.php?flag1=2&start1=$start1'>【上页】</a>【下页】【末页】</span>");
}elseif ($pagesize1 >= $num1 ){
print ("<span style='font-size: 9pt'>【首页】【上页】【下页】【末页】</span>");
}else{
print ("<span style='font-size: 9pt'><a href ='page_baidu.php?start1=0'>【首页】</a><a href ='page_baidu.php?flag1=2&start1=$start1'>【上页】</a><a href ='page_baidu.php?flag1=1&start1=$start1'>【下页】</a><a href ='page_baidu.php?start1=$lastpage1'>【末页】</a></span>");
}
//分页代码判断结束
print ("</td>
</tr></TABLE>");
mysql_free_result($result_product_type);
?>
考虑到安全问题,数据库信息部分已经省略。
运行结果请查看:
http://www.eternity2008.com/test/page_baidu.php
有问题请留言,或登陆http://www.eternity2008.com论坛联系。
<?php
$result_num1 = mysql_query("SELECT * FROM article");
$num1 = mysql_num_rows($result_num1);
$pagesize1 = 10;
$start1 = $_GET['start1'];
$flag1 = $_GET['flag1'];
//判断$start1是否有值
if ($start1 == null) {
$start1 = 0;
}
//判断完毕
//判断$flag1是否有值
if ($flag1 == null) {
$flag1 = 0;
}
//判断完毕
//判断标志位以确定$start1的值
if ($flag1 == 1 and $start1+$pagesize1 < $num1){
$start1 = $start1+$pagesize1;
}
if ($flag1 == 2 and $start1+$pagesize1 > 0){
$start1 = $start1-$pagesize1;
}
//判断完毕
$query_product_type = "SELECT art_title FROM article limit $start1, $pagesize1";
$result_product_type = mysql_query($query_product_type) or die("Query failed : " . mysql_error());
print ("<table width='100%'>
<tr>
<td valign='top' height = '188'>
<table width='100%'>");
while ($line_product = mysql_fetch_array($result_product_type, MYSQL_ASSOC)) {
print ("<tr>");
foreach ($line_product as $col_value_product_type) {
$result_product = mysql_query ("SELECT * FROM article WHERE art_title ='$col_value_product_type'");
$click_product = mysql_fetch_array($result_product) ;
print ("<td width='5%'><img border='0' src='../images/kind_list1.GIF' width='9' height='11'></td>");
print ("<td width='95%'><a href='view_article.php?art_title=$click_product[0]' target='view_article'><span style='font-size:
9pt'>$click_product[0]</span></a></td>");
}
print ("</tr>");
}
print ("</table>
</td></tr>");
//最后一页START标识
if (($num1 % $pagesize1) != 0){
$lastpage1 = $num1 - ($num1 % $pagesize1);
}else{
$lastpage1 = $num1 - $pagesize1;
}
//代码结束
//判断页数以及当前页代码
$pagenum1 = ceil($num1 / $pagesize1);
if ($start1 == 0){
$nowpage1 = 1;
}else{
$nowpage1 = ($start1 / $pagesize1) + 1;
}
//判断结束
print ("<tr>
<td><hr color='#314DA5' size='1' noshade style='border-style: dotted; border-width: 1px; padding: 0'></td>
</tr>
<tr>
<td><p align='center'><span style='font-size: 9pt'>第<font color = '#FF0000'><b>$nowpage1</b></font>页 | 共<font color =
'#FF0000'><b>$pagenum1</b></font>页 | 共<font color = '#FF0000'><b>$num1</b></font>条记录</span></td>
</tr>
<tr>
<td><p align='center'>");
//分页显示判断部分
if ($start1 == 0 and $pagesize1 < $num1){
print ("<span style='font-size: 9pt'>【首页】【上页】<a href ='page_baidu.php?flag1=1&start1=$start1'>【下页】</a><a href ='page_baidu.php?start1=$lastpage1'>【末页】</a></span>");
}elseif ($start1 >= $num1-$pagesize1 and $pagesize1 < $num1){
print ("<span style='font-size: 9pt'><a href ='page_baidu.php?start1=0'>【首页】</a><a href ='page_baidu.php?flag1=2&start1=$start1'>【上页】</a>【下页】【末页】</span>");
}elseif ($pagesize1 >= $num1 ){
print ("<span style='font-size: 9pt'>【首页】【上页】【下页】【末页】</span>");
}else{
print ("<span style='font-size: 9pt'><a href ='page_baidu.php?start1=0'>【首页】</a><a href ='page_baidu.php?flag1=2&start1=$start1'>【上页】</a><a href ='page_baidu.php?flag1=1&start1=$start1'>【下页】</a><a href ='page_baidu.php?start1=$lastpage1'>【末页】</a></span>");
}
//分页代码判断结束
print ("</td>
</tr></TABLE>");
mysql_free_result($result_product_type);
?>
考虑到安全问题,数据库信息部分已经省略。
运行结果请查看:
http://www.eternity2008.com/test/page_baidu.php
有问题请留言,或登陆http://www.eternity2008.com论坛联系。
展开全部
<?php include("a.php");?>
<?php
$id=$_POST["id"];
$title=$_POST["title"];
$db=new ctrldb("localhost","root","blog");
if($id!=null)
{
$sql="insert into document (id,title) values('$id','$title')";
$db->excut($sql);
}
?>
<form action="index.php" method="POST">
<table border="1">
<tr>
<td><input type="text" name="id"></td><td><input type="text" name="title"></td>
</tr>
<tr>
<td><input type="submit" name="ok" value="提交"></td><td><input type="button" name="cencel" value="取消"></td>
</tr>
</table>
</form>
<div style="border:1px solid #000000;">
<?php
$page=1;
if(isset($_GET['page']))$page=$_GET['page'];
$sqlnum="select * from document";
$allCount=$db->getRowNum($sqlnum);//数据库中的总记录数
$pagenum=5;//每页显示5条记录
if(($allCount/$pagenum)>1)
{
$pages=ceil($allCount/$pagenum)+1;//一共有多少页
}
else {
$pages=ceil($allCount/$pagenum);
}
echo $start=$page*$pagenum;//开始的记录号
$sql_page="select * from document LIMIT $start,$pagenum";
foreach ($db->query($sql_page) as $item)
{
echo $item["title"];
echo "<br>";
}
echo "<a href=index.php?page=".($page-1)."> << </a>";
echo "<a href=index.php?page=".($page+1)."> >> </a>";
?>
</div>
赶紧给我分吧
这是我以前做的
100%对
追加50
<?php
$id=$_POST["id"];
$title=$_POST["title"];
$db=new ctrldb("localhost","root","blog");
if($id!=null)
{
$sql="insert into document (id,title) values('$id','$title')";
$db->excut($sql);
}
?>
<form action="index.php" method="POST">
<table border="1">
<tr>
<td><input type="text" name="id"></td><td><input type="text" name="title"></td>
</tr>
<tr>
<td><input type="submit" name="ok" value="提交"></td><td><input type="button" name="cencel" value="取消"></td>
</tr>
</table>
</form>
<div style="border:1px solid #000000;">
<?php
$page=1;
if(isset($_GET['page']))$page=$_GET['page'];
$sqlnum="select * from document";
$allCount=$db->getRowNum($sqlnum);//数据库中的总记录数
$pagenum=5;//每页显示5条记录
if(($allCount/$pagenum)>1)
{
$pages=ceil($allCount/$pagenum)+1;//一共有多少页
}
else {
$pages=ceil($allCount/$pagenum);
}
echo $start=$page*$pagenum;//开始的记录号
$sql_page="select * from document LIMIT $start,$pagenum";
foreach ($db->query($sql_page) as $item)
{
echo $item["title"];
echo "<br>";
}
echo "<a href=index.php?page=".($page-1)."> << </a>";
echo "<a href=index.php?page=".($page+1)."> >> </a>";
?>
</div>
赶紧给我分吧
这是我以前做的
100%对
追加50
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询