English 中文(简体)
老龄化和遗传状态
原标题:Paging and edit category status
  • 时间:2010-04-03 19:16:58
  •  标签:
  • php

对于第一类的ed户家庭状况,有以下联系:

<span class="ha" title="Active in Homepage">Active in Homepage</span><a href="?page=homestatus&id={$row[ id ]}" class="hp"  title="">Passive in home page</a>

(b) :

function homestatus() {
  $ID     = mysql_real_escape_string($_GET[ id ]);
  $query  = "UPDATE category SET home = 0  WHERE id= $ID ";
  $result = mysql_query($query);
    if (mysql_affected_rows () == 1) {
       header( Location: index.php?page=categories );
      }
 }

一切工作都得到罚款,但是有:

/index.php?page=categories&pg=2

I want that an item located in pg=2, redirected to index.php?page=categories&pg=2 How can I do this? Thanks in advance

印刷功能:

function Pages($tbl_name,$limit,$path){

$query = "SELECT COUNT(*) as num FROM $tbl_name";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
$adjacents = "2";
$pg = $_GET[ pg ];
if($pg)
    $start = ($pg - 1) * $limit;
else
    $start = 0;

$sql = "SELECT id FROM $tbl_name LIMIT $start, $limit";
$result = mysql_query($sql);

if ($pg == 0) $pg = 1;
    $prev = $pg - 1;
    $next = $pg + 1;
    $lastpage = ceil($total_pages/$limit);
    $lpm1 = $lastpage - 1;

    $pagination = "";
if($lastpage > 1)
{   
    $pagination .= "<div class= pagination >";
if ($pg > 1)
    $pagination.= "<a href= ".$path."pg=$prev  class="prev">« Önecki</a>";
else
    $pagination.= "<span class= disabled >« Önceki</span>";   

if ($lastpage < 7 + ($adjacents * 2))
{   
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $pg)
    $pagination.= "<span class= current >$counter</span>";
else
    $pagination.= "<a href= ".$path."pg=$counter >$counter</a>";                   
}
}
elseif($lastpage > 5 + ($adjacents * 2))
{
if($pg < 1 + ($adjacents * 2))       
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $pg)
    $pagination.= "<span class= current >$counter</span>";
else
    $pagination.= "<a href= ".$path."pg=$counter >$counter</a>";                   
}
    $pagination.= "...";
    $pagination.= "<a href= ".$path."pg=$lpm1 >$lpm1</a>";
    $pagination.= "<a href= ".$path."pg=$lastpage >$lastpage</a>";       
}
elseif($lastpage - ($adjacents * 2) > $pg && $pg > ($adjacents * 2))
{
    $pagination.= "<a href= ".$path."pg=1 >1</a>";
    $pagination.= "<a href= ".$path."pg=2 >2</a>";
    $pagination.= "...";
for ($counter = $pg - $adjacents; $counter <= $pg + $adjacents; $counter++)
{
if ($counter == $pg)
    $pagination.= "<span class= current >$counter</span>";
else
    $pagination.= "<a href= ".$path."pg=$counter >$counter</a>";                   
}
    $pagination.= "..";
    $pagination.= "<a href= ".$path."pg=$lpm1 >$lpm1</a>";
    $pagination.= "<a href= ".$path."pg=$lastpage >$lastpage</a>";       
}
else
{
    $pagination.= "<a href= ".$path."pg=1 >1</a>";
    $pagination.= "<a href= ".$path."pg=2 >2</a>";
    $pagination.= "..";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $pg)
    $pagination.= "<span class= current >$counter</span>";
else
    $pagination.= "<a href= ".$path."pg=$counter >$counter</a>";                   
}
}
}

if ($pg < $counter - 1)
    $pagination.= "<a href= ".$path."pg=$next >Sonraki »</a>";
else
    $pagination.= "<span class= disabled >Sonraki »</span>";
    $pagination.= "</div>
";       
}


return $pagination;
}
最佳回答

我认为,你们需要做的是获得<代码>pg>的可变性,并将其添加到中方向。 在<代码>标题<>前添加以下线: (is_ amountic() 检查是为了安全。

 if (is_numeric($_GET["pg"]))
  $page = "&pg=".$_GET["pg"];
 else
  $page = null; 

 header("Location: index.php?page=categories$page");

http://www.hchr.org。

你们是否寻求想象解决办法? 在SO方面已经有一些。 相关问题:

More on SO

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签