kayakn Posted August 28, 2007 Share Posted August 28, 2007 Thanks ahead of time for your patience. I am currently using PHP 5 MySQL 5 and Apache2 I have repetitive queries to a DB that includes a request for a Named Anchor. <ul><li> <A href="<?php $field = 'id=22'; include '../inc/query_.php'; echo "#".$row['link']; ?>"> <?php echo $row['name']; ?></A> </li></ul> <?php $field = 'id=22'; ?> // id loops from 1-30 <?php include '../inc/query_.php';?> <?php include '../inc/test.inc.php';?> ...from test.inc.php.... <a name="<?php echo $row['link']; ?>"></a> Since Test.inc.php has a page of text, I would expect the Named Anchor to appear at the top of each page. However, it appears to be placed at the top of the first page for every "id". I have used id instead of name, to no avail, I have used both in the tag, to no avail. If I hard code the page, it works correctly. When I view page source, it reads correctly. I am sure I am missing some piece of knowledge that will make this work. How do I make sure that the page interprets the correct location for the anchor? Regards, kayakn Quote Link to comment https://forums.phpfreaks.com/topic/66958-named-anchors-from-db/ Share on other sites More sharing options...
Fadion Posted August 28, 2007 Share Posted August 28, 2007 I cant get my brain to understand this. Please post some more code and wrap them all in code tags. Quote Link to comment https://forums.phpfreaks.com/topic/66958-named-anchors-from-db/#findComment-335800 Share on other sites More sharing options...
kayakn Posted August 28, 2007 Author Share Posted August 28, 2007 Here is a complete page wrapped in code tags. Sorry for the newb mistake <code> <? include '../inc/header.php'; ?><!-- this has the proven Db Connection --> <!------------------------------------------------Quicklinks begin-------------------------------> <A href="<?php $field = 'id=22'; include '../inc/query_.php'; echo "#".$row['link']; ?>"><?php echo $row['name']; ?></A> <!------------------------------------------------Quicklinks loop 1-30-------------------------------> <!------------------------------------------------Quicklinks end-------------------------------> <!------------------------------------------------page 1 starts----------------------------------------------> <?php $field = 'id=22'; ?> <?php include '../inc/query_.php';?> <!------------------------------------------------Anchor at beginning of Page 1-------------------------------------------> <a name="<?php echo $row['link']; ?>"></a> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum......<!--- repeated ad naseum --> <!------------------------------------------------page 1 starts----------------------------------------------> <?php $field = 'id=23'; ?> <?php include '../inc/query_.php';?> <!------------------------------------------------Anchor at beginning of Page 2-------------------------------------------> <a name="<?php echo $row['link']; ?>"></a> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum......<!--- repeated ad naseum --> <? include '../inc/footer.php'; ?> </code> Quote Link to comment https://forums.phpfreaks.com/topic/66958-named-anchors-from-db/#findComment-335825 Share on other sites More sharing options...
Fadion Posted August 28, 2007 Share Posted August 28, 2007 it should be code within [] and not <>, like [ code ] without spaces. Is this snippet working? I can see includes and stuff in an anchor. What is: $field = 'id=22'? Normally for what u want to do u should have: $query = mysql_query("blah blah"); //show links while($values = mysql_fetch_array($query)){ echo "<a href="\#{$values['link']}\">Link</a>; } //show texts while($values = mysql_fetch_array($query)){ echo "<a name=\"{$values['name']}\" />"; echo $values['text']; } So you have links at the top and articles or whatever at the bottom. Isnt this what u wanna acomplish? Quote Link to comment https://forums.phpfreaks.com/topic/66958-named-anchors-from-db/#findComment-335833 Share on other sites More sharing options...
kayakn Posted August 28, 2007 Author Share Posted August 28, 2007 I would expect the Named Anchor to jump to the paragraph it is attached to, let's say 250 lines down. Instead, there is no scrolling and the anchors seem to go to the same spot, let's say line 10. If I have the following code: line 1 <html> line 2 blah blah line 3 <a href="#link">link</a> ...... line 10 <a name="link"></a><p this is the paragraph written in HTML.</p> </html> You would expect it to jump to line 10. But if this was a PHP page, and lines 4-9 were an include that had 50 lines of text, then wouldn't the anchor be on line 51? I need the Anchor to be dynamically created (not a problem) and then have the anchor be (in this example) line 51. Clear as mud?? Quote Link to comment https://forums.phpfreaks.com/topic/66958-named-anchors-from-db/#findComment-335953 Share on other sites More sharing options...
kayakn Posted August 28, 2007 Author Share Posted August 28, 2007 Is there anything else I can give you that will explain this more clearly? K Quote Link to comment https://forums.phpfreaks.com/topic/66958-named-anchors-from-db/#findComment-336259 Share on other sites More sharing options...
Fadion Posted August 28, 2007 Share Posted August 28, 2007 I understand clearly what u are doing but i need some more code to help u debug. Pls post some more and use [ code ] [ /code ] without spaces. Quote Link to comment https://forums.phpfreaks.com/topic/66958-named-anchors-from-db/#findComment-336270 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.