View Single Post
Old 12-02-2012, 10:40 PM   PM User | #1
jadeallencook
New to the CF scene

 
Join Date: Dec 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
jadeallencook is an unknown quantity at this point
Unhappy PHP Increment/Decrement

This might sound a bit noobish but I am having trouble creating a increment/decrement button. So basically, I created a website that uses Tumblr feed to view photos that I've tagged. For example, if I pass a variable called "nav" that equals california, it will show all of my photos from california by using this code.

Code:
<?php
$location = $_GET['nav'];
echo "<script src='http://myblog.tumblr.com/tagged/" . $_REQUEST["nav"] . "/js' type='text/javascript'></script>";
?>
But the problem I am having is that it only shows the first 10 photos and in order for me to view the next page I have to add this into the code.

Code:
<?php
$location = $_GET['nav'];
echo "<script src='http://myblog.tumblr.com/tagged/" . $_REQUEST["nav"] . "/page/2/js' type='text/javascript'></script>";
?>
And so on...

I want to be able to add a button to change the variable after "page/". And another thing is, the first page cannot read "page/1", because when I do it doesn't show anything. So the first page has to be the first script, and then after they press a "next" button, it has to go to the second code. I've gotten this so far:

Code:
<?php
$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/" . $_REQUEST["job"] . "/js' type='text/javascript'></script>";
}
else
{
   echo "<script src='http://myblog.tumblr.com/tagged/" . $_REQUEST["job"] . "page/" . $page . "/js' type='text/javascript'></script>";
}
?>

<form method="POST">
<input type="hidden" name="navigation" value="location" />
<input type="submit" name="previous" value="previous">
<input type="submit" name="next" value="next">
<input type="hidden" name="navigation" value="<?php echo $location; ?>" />
</form>
But nothing seems to work /:
jadeallencook is offline   Reply With Quote