Jump to content

Naming anchor via link to database


Recommended Posts

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\" /]

Link to comment
Share on other sites

Hmmm.

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.

Lite...
Link to comment
Share on other sites

  • 2 weeks later...
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\" /]
Link to comment
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.