SparkleGirlSparkle Posted May 31, 2006 Share Posted May 31, 2006 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\" /] Quote Link to comment https://forums.phpfreaks.com/topic/10897-naming-anchor-via-link-to-database/ Share on other sites More sharing options...
litebearer Posted May 31, 2006 Share Posted May 31, 2006 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... Quote Link to comment https://forums.phpfreaks.com/topic/10897-naming-anchor-via-link-to-database/#findComment-40721 Share on other sites More sharing options...
SparkleGirlSparkle Posted June 10, 2006 Author Share Posted June 10, 2006 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\" /] Quote Link to comment https://forums.phpfreaks.com/topic/10897-naming-anchor-via-link-to-database/#findComment-44149 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.