variables and forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

variables and forms

Post by John Cartwright »

I'm somewhat new in php and I was wondering if someone could point me in the right direction about this. I am setting up a bunch of forms which allow an administrator to change certain contents of the site, for example:

A news page
or a Releases page

How could you allow forms to call up the data and then be able to modify it. Another thing is, using the news page as an example, when you create a new news article, the past news is shuved down the list, so when viewing the news page your articles r from newest to oldest.

That should be more than enough to get it started, althought this is going to grow into a somewhat bigger project. Could someone please show me a tutorial on this kind of thing, and recommend if using a database is appropriate ( obviously it is ) but if there is a better way to do it.

TY ALOT! :D
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

Using a database is the right idea.

You'd have a database table that contained everything about the different news articles. For example:

Table Name: news
Database Fields: id, title, body, date, author, authorEmail

Then your form would populate those database fields with the form content.

When you output the news articles you can basically say (using SQL), "Get me the 5 most recent articles, ordered by date."

Anyway, here's a quick tutorial from Zend that introduces you to using databases and PHP together.

http://www.zend.com/zend/tut/tutorial-yank.php

It uses Jokes rather than News as the example, but you'll get the idea.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Thanks alot... I'll be back when I got more questions,

but my other part of my post how do I get forms to change the information in the database
Post Reply