There are probably several ways to do this. This is probably the easiest way to understand conceptually:
- Code: Select all
<?php
$location = $_REQUEST['nav'];
$page = $_REQUEST['page'];
if ($page <= 1)
{
echo "<script src='http://myblog.tumblr.com/tagged/" . $location . "/js' type='text/javascript'></script>";
}
else
{
echo "<script src='http://myblog.tumblr.com/tagged/" . $location . "page/" . $page . "/js' type='text/javascript'></script>";
}
?>
Of course, in order for this to work, you'll have to keep track of which page you're on. There are again several ways you could do this, but the easiest is probably to keep the current page number in a hidden form field. Then, just have a "next" button and a "previous" button, and check which one was clicked by testing to see if the appropriate $_POST index is set:
- Code: Select all
$location = $_REQUEST['nav'];
$page = $_POST['page'];
if (isset($_POST['next']))
{
$page++;
}
else if (isset($_POST['previous']))
{
$page--;
}
if ($page <= 1)
{
echo "<script src='http://myblog.tumblr.com/tagged/" . $location . "/js' type='text/javascript'></script>";
}
else
{
echo "<script src='http://myblog.tumblr.com/tagged/" . $location . "page/" . $page . "/js' type='text/javascript'></script>";
}
That should be enough to get you started. I'd also suggest thinking about how you can disable the previous or next buttons when you are on the first or last page of their range - with the code above, what happens if you click the "previous" button while you're on page 1? Then what happens if you click the next button?
If you have any questions or if I wasn't clear about something, please let me know and I'll try to explain further. =)