Spunky Posted January 18, 2010 Share Posted January 18, 2010 Regular link: main.htmlAnchored link: main.html#top (#top being the name of the anchor)Link with PHP from a database: main.php?type=generalMy question is is can I turn the PHP link into an anchor so when it shows the data from the database it also jumps to a part of the page that I tell it to? I use anchor tags all over my website because I like the use of it NOT jumping to the top of the page everytime you click on something, and instead, taking you to where you want to go, saving you the effort of scrolling down all the time. People have seen the top plenty, thank you, they dont need to see it more, hehe. So, but when I have a link on the page show data from my database, it instantly jumps to top. How to fix?Please and thank you! Link to comment Share on other sites More sharing options...
Synook Posted January 18, 2010 Share Posted January 18, 2010 You can just print out the anchor bit when you echo the link. Link to comment Share on other sites More sharing options...
Spunky Posted January 18, 2010 Author Share Posted January 18, 2010 You can just print out the anchor bit when you echo the link.Ok can you like give an example or something? I have no idea what you mean by "print". Link to comment Share on other sites More sharing options...
Err Posted January 18, 2010 Share Posted January 18, 2010 Pretty sure he meant: $link = "main.php?type=general";echo "$link#top"; echo is what is commonly used to print things on page. Link to comment Share on other sites More sharing options...
Spunky Posted January 19, 2010 Author Share Posted January 19, 2010 Pretty sure he meant:$link = "main.php?type=general";echo "$link#top"; echo is what is commonly used to print things on page. Ok, yea, I get what echo means now. I've never actually used PHP, I only use it to link to my database and thats it. I am still in the process of learning it.So here is what I did based on the little knowledge that I have:In my head area I put:<?php$link = "achievements.php?type=general";echo "$link#top";?> And I put my anchor tag where I wanted it: <a name="top" class="top"> And when I refreshed the page, on the very top of the page above everything it put:achievements.php?type=general#topClearly I did something wrong. Help please? :)Oh and the code used for the link is: <a href="achievements.php?type=general"> This is placed in the body of the page. Link to comment Share on other sites More sharing options...
Synook Posted January 19, 2010 Share Posted January 19, 2010 Err, I meant the actual link to the page, as in: <!-- where people click to go to achievements.php --><a href="<?php echo "achievements.php?type=general#top"; ?>">Click</a> Link to comment Share on other sites More sharing options...
Spunky Posted January 20, 2010 Author Share Posted January 20, 2010 Err, I meant the actual link to the page, as in:<!-- where people click to go to achievements.php --><a href="<?php echo "achievements.php?type=general#top"; ?>">Click</a> OH lol, duh. Sorry, as I said Im still new to php. I didn't know you could integrate it like that.Thanks so much it works!! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.