ich SEO-freundliche URLs mit .htaccess Mod Rewrite wie diese erstellen möchten:erstellen SEO-freundliche URLs mit .htaccess Mod Rewrite
http://localhost/try/pagination/page/4
aber jetzt Ausgabe zeigt, wenn wir Sie auf Next-Button
http://localhost/try/pagination.php/page/pagination.php/page/2
Meine pHP-Code ist:
<?php
//include 'config.php';
define('DB_HOST', 'localhost');
define('DB_NAME', 'wr');
define('DB_USER','root');
define('DB_PASSWORD','');
$con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
$db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error());
echo $_GET['page'];
$rowsPerPage = 1;
if(isset($_GET['page']))
{
$pageNum= $_GET['page'];
}
else
$pageNum = 1;
$previousRows =($pageNum - 1) * $rowsPerPage;
$query = "SELECT * FROM articles LIMIT $previousRows, $rowsPerPage";
$result = mysql_query($query) or die('Error couldn\'t get the data').mysql_error();
echo "<table border=1>\n";
echo "<tr><th>ID</th><th>Name</th><th>Password</th><th>Perm</th><th>Email</th>
<th>Date</th></tr>";
while(list($id,$title,$content) = mysql_fetch_array($result))
{
echo "<tr><td>$id</td><td>$title</td><td>$content</td></tr>";
}
echo '</table>';
$query = "SELECT COUNT(title) AS numrows FROM articles";
$result = mysql_query($query) or die('Error, couldn\'t get count title=\"$page\"').mysql_error();
$row = mysql_fetch_assoc($result);
$numrows = $row['numrows'];
$lastPage = ceil($numrows/$rowsPerPage);
echo $lastPage;
$phpself = "pagination.php";
echo $phpself;
if ($pageNum > 1)
{
$page = $pageNum - 1;
$prev = " <a href=\"$phpself?page=$page\" title=\"Page $page\">[Back]</a> ";
$first = " <a href=\"$phpself?page=1\" title=\"Page 1\">[First Page]</a> ";
}
else
{
$prev = ' [Back] ';
$first = ' [First Page] ';
}
if ($pageNum < $lastPage)
{
$page = $pageNum + 1;
$next = " <a href=\"$phpself/page/$page\" title=\"Page $page\">[Next]</a> ";
$last = " <a href=\"$phpself?page=$lastPage\" title=\"Page $lastPage\">[Last Page]</a> ";
}
else
{
$next = ' [Next] ';
$last = ' [Last Page] ';
}
echo $first . $prev . " Showing page <bold>$pageNum</bold> of
<bold>$lastPage</bold> pages " . $next . $last;
?>
.htaccess-Code ist:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^pagination/page/([0-9]+)\.html$ pagination.php?page=$1
nächste Anforderung ist, wenn wir die beiden variablen
http://localhost/try/pagination/tag/php/page/2
passieren sind, wie ich in PHP-Code und .htaccess
Datei ändern?
'mysql_' \ * ahem \ *: https://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql -functions-in-php – CD001
'http: // localhost/wr/versuchen/pagination.php/page/pagination.php/Seite/2 ist das * wirklich * die URL? 2x 'pagination.php' drin? ... und wo haben Sie dieses Muster gefunden: 'RewriteRule^Paginierung/([0-9] +) \. html $ pagination.php? page = $ 1' - das ist nur umschreiben Dinge wie * Paginierung/123.html * und scheint nicht zu Ihren Anforderungen überhaupt zu passen ... – CD001
jetzt den Beitrag aktualisieren und bitte geben Sie mir Lösung – ashwani