Reputation: 536
i want to build html sitemap with 500 link for each sitemap page. my site has more than 10,000 post.
my sitemap.php file
$sql = mysql_query("SELECT * FROM post WHERE id BETWEEN 1 AND 500" );
while($data = mysql_fetch_array($sql))
{
echo "<a href='http://".$data['url']. "'>".$data['title']. "</a>";
echo "<br>";
}
how to get another 500 post via URL parameter?
/sitemap.php?=2 or
/sitemap.php?=501&1000
Upvotes: 0
Views: 168
Reputation: 1412
/sitemap.php?=2 or
/sitemap.php?=501&1000
This won't work. You will have to use parameter names, e.g. like this:
/sitemap.php?page=2
Then get the parameter values using $_REQUEST:
$page = $_REQUEST['page'];
and perform the query accordingly:
$sql = mysql_query("SELECT * FROM post WHERE id BETWEEN " . (($page - 1) * 500) . " AND " . ($page * 500));
P.S. I know, I know... SQL injection, parameter validation, etc. That was not the point.
Upvotes: 2