Page 1 of 1

Brain... fading... need... PHP/DB advice...

Posted: Tue Oct 25, 2005 1:03 pm
by Noobie
Hi all

I'll preface everything I say by saying now that I really am a noobie on the whole PHP/MYSQL interaction thing. I'm trying to get my head around dynamic rather than nice easy safe static sites - with the help of books, web tutorials etc - I'm crawling along very gradually.

Ok so excuses over.

I'm working on a site with a news section which will have a date and brief summary of each item on the main news page and each summary will link through to the full text of that story. There'll also be a link to a page with all the news items listed in full one after another.

I've spent all day setting up the MYSQL database and (finally) getting a really simple form to update the database working. Now my brain seems to have shut down completely - so I was hoping you good people out there could just tell me if I'm going in the right direction with regards to the rest of the stuff.

So, the database has fields for date, news summary and full text. Am I right in thinking that the news page should therefore have a query to list all the summaries in a list and make those summaries links to the second page (but only calling the specific full story chosen via id) - whereas if the user just uses the straight link to the second page it would call all the stories?

Also - I'm planning on adding some code to ensure that paragraphs are added where necessary and special characters are dealt with properly. Do I need to add that code just on the pages where the news items are actually returned?

I don't want anyone to have to write code for me (I have to learn!) but if you could let me know if I'm heading the right way I'd be really grateful.

Posted: Tue Oct 25, 2005 1:26 pm
by RobertGonzalez
I would say yes, you are heading in the right direction. Basically list a set number of results from an initial query in one page (list.php) where the list consists of links to the a detail page (detail.php). On the detail page check to see if there is a querystring value set for some var, in this case maybe $article_id, and if so, show that article. If not, show the detailed list of articles.

Yeah, you are on the right track.

Posted: Tue Oct 25, 2005 2:58 pm
by Noobie
Thanks Everah

Now I know I'm sort of doing the right thing it'll make life a lot easier! :D

Posted: Tue Oct 25, 2005 3:25 pm
by RobertGonzalez
No problem Noobie. When I was first starting out in PHP development I asked almost this same question here. It is actually a fairly reasonable and common thing to do, list then detail. In fact, these forums do the same thing. The index page list the forum list. Click on a forum name and it lists the posts. Click on a post and it shows the thread and all responses to the thread.

Ah, the power of database and script interaction. Isn't it a beautiful thing?