我有一种问题,使用以下 php 代码:
$host="localhost";
$user_name="";
$pwd="";
$database_name="";
$conexiune = mysql_connect($host,$user_name,$pwd) or die("Nu ma pot conecta la MySQL!");
mysql_select_db($database_name, $conexiune) or die("Nu gasesc baza de date");
if (isset($_GET["page"])) {
$page = $_GET["page"];
} else {
$page=1;
};
$start_from = ($page-1) * 1;
$sql = "SELECT * FROM citate ORDER BY id DESC LIMIT $start_from, 1";
$rs_result = mysql_query ($sql,$conexiune);
while ($row = mysql_fetch_assoc($rs_result))
echo "<img src='" . $row['poza'] . "' />
<br />
" . $row['titlu'] . "
<br />
" . $row['descriere'] . "
<br />
" . $row['data'] . "
";
$sql = "SELECT COUNT(id) FROM citate";
$rs_result = mysql_query($sql,$conexiune);
$row = mysql_fetch_row($rs_result);
$total_records = $row[0];
$total_pages = ceil($total_records / 1);
$pagelink ='<a href="lista.php?page='.($page-1).'"><<</a> ';
$pagelink_2='<a href="lista.php?page='.($page+1).'">>></a> ';
if($page>1)
echo $pagelink;
if($page<2)
echo "";
for ($i=1; $i<=$total_pages; $i++) {
if ($i != $page)
echo "<a href='lista.php?page=".$i."'>".$i."</a> "; // xxxx = your page url address
if ($i==$page)
echo " <strong>". $i . "</strong> "; // defining class in the style sheet you can add colour or border to the displayed number
};
if($page<$total_pages)
echo $pagelink_2;
该代码为我提供了分页(你已经知道了),并且 url 栏地址如下所示:
http://www.site.ro/folder/lista.php?page=PAGE-NUMBER
我想看起来像以下: http ://www.site.ro/folder/lista.php?citat=SOME-NUMBERS&page=PAGE-NUMBER
我的数据库表是这样填充的:
--------------------------------------------------------------
| id | poza | titlu | descriere | citat | data | accesari |
--------------------------------------------------------------
我想从“citat”列中提取数据,所以来自 url 栏的链接将如下所示:
http://www.site.ro/folder/lista.php?citat=EXTRACTED-FROM-CITAT&page=PAGE-NUMBER
每次我按下下一页按钮时,都会如下所示:
http://www.site.ro/folder/lista.php?citat=2748925&page=1
http://www.site.ro/folder/lista.php?citat=2840194&page=2
等等..我该如何修改该代码?预先感谢 !