dtsdave Posted March 13, 2006 Share Posted March 13, 2006 Hello. I've read a book, searched the web, read articles, and scoured forums and still am stumped. I think I'm missing something fundamental and that's why I haven't been able to find the answers I'm looking for.Basically, I'm trying to create pages from the data I've put into MySQL. For example, say I've got a database that stores article ids, titles and content. I want to create one template that will display the title of a given article and the content.I know how to get the info into MySQL. My problem is how to create pages for individual articles. I want to be able to go to [a href=\"http://www.site.com/article1\" target=\"_blank\"]http://www.site.com/article1[/a] and it'll have a page with the title and content for article 1, [a href=\"http://www.site.com/article2\" target=\"_blank\"]http://www.site.com/article2[/a] and it'll have a page with the title and content for article 2, and so on. I know naming the URLs will probably be tricky and that's not my concern right now. I'm just trying to display different articles with just one template as opposed to writing a separate template for each article.I hope I was clear in stating my problem. Any help would be greatly appreciated. Thank you very much in advance. Quote Link to comment Share on other sites More sharing options...
kamiza Posted March 13, 2006 Share Posted March 13, 2006 Are you talking about Pagination or just dynamic pagesIf talking about dynamic pages then something like this:You can have?article=#EX: news.php?article=1, news.php?article=2then when you call up the articles something like this:[code]switch($_GET['article']){ case '1': article1(); break; case '2': article2(); break;}[/code]Calling the function article1which would be[code]function article1() { //script to get article1 out of mysql}[/code]Could even have just 1 function and then have that switch statement in the function and then have $_GET['article']'s value get article# out of mysqlBut just giving an exampleI'm pretty new at php too Quote Link to comment Share on other sites More sharing options...
keeB Posted March 13, 2006 Share Posted March 13, 2006 The approach I would take to solving this problem is to break it down into what needs to be accomplished:[ol type=\'1\'][*]Design the back-end (database)[*]Design all objects / functions for retrieving data and information[*]Design a page that dynamically displays data based on URL[*]Design a Template (UI.. how it will look)[/ol]With those items in mind, it's not hard to see what needs to be done.Think of a sample table ARTICLES[code]CREATE TABLE articles (articleID int(3) not null,title varchar(20) not null,text longtext not null)[/code]and consider this url..[code]http://www.domain.com/article.php?id=1[/code]and..[code]select * from articles where articleID = 1[/code]catch my drift?? Quote Link to comment Share on other sites More sharing options...
dtsdave Posted March 14, 2006 Author Share Posted March 14, 2006 kamiza and keeB, thank you very much for your posts! You've got me on the right track and have been a big help. Quote Link to comment 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.