Jump to content
plugnz14

PHP_SELF refresh

Recommended Posts

Hi , having some fun trying to get my blog to refresh at a section on my page rather than the top of the page. I'm using Simple Blog PHP 3.0 script which uses a PHP include()to insert the blog entry on the page.  

The bit that posts the blog entry...

Quote

<a href="<?php echo $thisPage; ?>?pid=<?php echo $Newer_Post; ?>&amp;p=<?php echo $_REQUEST['p']; ?>&amp;cat_id=<?php echo $_REQUEST["cat_id"]; ?>&amp;search=<?php echo urlencode($_REQUEST["search"]); ?><?php echo $anchor_blt; ?>" title="<?php ReadHTML($Post['post_title']); ?>">
                            <?php echo ReadDB($OptionsLang["Newer_Post"]); ?> <i class="fa fa-angle-right"></i>    </a>

and the bit that sends it back to itself

Quote

$thisPage = $_SERVER['PHP_SELF'];

My page has sections, every time it refreshes back to the top of the page, with this in the address bar

Quote

http://www.ak-tiv.co.nz/ak-tivblog.php?pid=3&p=

But I'd like it to go to the # Blog section of the page. So I've tried this..... 

Quote

$thisPage = $_SERVER['PHP_SELF']. '#blog';

.....and it works! wahoo! Refreshes back to the blog section of the page and this bit in the address bar....

Quote

http://www.ak-tiv.co.nz/ak-tivblog.php#blog?pid=3&p=

but.... now the blog links don't work....

Any thoughts? I would be very much appreciative if someone could shed some light on this. Thanks in advance.
                   

Share this post


Link to post
Share on other sites

It's trying to echo a variable called $anchor_bit in the URL, you should set that variable to "#blog".  The anchor goes at the end of the URL, not before the querystring.

Share this post


Link to post
Share on other sites

Here was the offending variable.....

 

Quote

// adding anchor to URLs. Comment if no need of anchors
//$comm_url = $url_vars."#comment";
$url_vars .= "#blog";

// adding anchor to URLs. Make it $anchor_blt = "#blt"; if you need anchors
$anchor_blt = "#blog";

Thanks again for your help. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×