Jump to content


Naming anchor via link to database

  • Please log in to reply
2 replies to this topic

#1 SparkleGirlSparkle

  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 31 May 2006 - 08:41 PM

Background: I'm creating a news system using a database, so that I update the database with any news and (because of the coding) will automatically update on my website.

So far, I have scripted my pages so that a title and summary of a news item appears on the homepage, followed by a link to the main news page.
The main news page is scripted so that everything in the database shows up.

My aim is to be able to add an anchor to each of the news articles on the main page, the name of the anchor to be determined by the id in the database. But I cannot figure out how to make that happen.

Once that is achieved, I also need to be able to rescript to the link on the home page so that it will take you to the actual news article, so rather than having www.mysite.com/news, the link could then be www.mysite.com/news#2 (again, scripting it so it automatically adds the appropriate id to the link.)

I've no idea if this is possible, but it's worth a try at finding out. Otherwise I'm quite happy to stick with all the articles on one page and making my readers sift their way through the articles! [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /]

#2 litebearer

  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 31 May 2006 - 10:33 PM


Working backwards is always a good method.

create yourself a simple sample page (no need for more than 3 test links/anchors). use the article id from the database as the name of the anchor tags. hard code it, do NOT use php or mysql yet.

then create the 'index' page (the one that has the links TO the articles on the first file).

at that point ask yourself how you would use php to change the names of the anchor tags/links.

I think you'll grab the process quickly.


all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#3 SparkleGirlSparkle

  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 10 June 2006 - 11:46 PM

Thanks for the advice! Following your suggestions I was able to create what I wanted to achieve, and it was a lot simpler than I thought, mainly because I was under the impression I needed to create it in a different way. Anyway common sense, and a little trial and error, have prevailed and I have completed the task! So thanks again for the pointers! [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users