Jump to content

Archived

This topic is now archived and is closed to further replies.

SparkleGirlSparkle

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

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites
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\" /]

Share this post


Link to post
Share on other sites

×

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.