Jump to content

Recommended Posts

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

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/66958-named-anchors-from-db/
Share on other sites

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>

 

Link to comment
https://forums.phpfreaks.com/topic/66958-named-anchors-from-db/#findComment-335825
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/66958-named-anchors-from-db/#findComment-335833
Share on other sites

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??

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/66958-named-anchors-from-db/#findComment-335953
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.