How to get started on your first PHP/MySQL app
Posted by The Technocrat | Filed under Coding, Geeky
We've all got great ideas for the next big thing. Before you invest in a personalized license plate that says 'Web20' or 'AJAX 7334', you'll need to develop a simple way of getting information in and out of a web server.
There are many ways to do this, but I like PHP and MySQL, because they are easy and cheap. (PHP and MySQL are free, but you can find hosting on a PHP-MySQL server for as low as $8/month.)
So let's say we want to build a web app…
Step 1: lay out what info you're going to need
I think of it like this: if you were to do this process on paper, what would you need? First of all, you'll need User information. On a 'User Information' sheet, I might have the following info:
User Info
- First Name
- Last name
- Employee ID number
- Email Address
OK, so that's pretty easy to figure out. It's also easy to take this info and plan out how you're going to store the info in a MySQL table. (a MySQL table is like a spreadsheet in Excel (OpenOffice Calc!)) So I will take my data requirements and make a table called user_info, as follows. I will also define what will be in each data type. I also need to add some more fields…
(* this data will be required to be unique – I can't have 2 users with the same name!) This is going to lay out a table in MySQL that looks like this when it is full:
user_info
user_id
passwd
fname
lname
email
php_ddy
phpisneat
John
Doe
jdoe@isp.com
supr_lady
mysqlissweet
Jane
Doe
janed@isp.com
Each row is called a record, and contains all of that person's info. The user info table is pretty standard, but what other tables you will need depend on your application. Let's say we're making a simple chat room web page. Another table we will need will be for people's comments, like this:
Now the important thing to notice here is my re-use of user_id. By re-using this data, I can now link the two tables together.
user_id
time_posted
date_posted
text
php_ddy
13:10:09
03-15-2006
hi jane!
supr_lady
13:10:13
03-15-2006
hi john, what's up?
php_ddy
13:10:17
03-15-2006
nothing much, just saying hi.
3 Responses to “How to get started on your first PHP/MySQL app”
Leave a Reply
April 29, 2006 at 10:56 pm
good basic article, it was fluent. are you going to write more on the subject?
April 30, 2006 at 8:21 am
sure am, gotta start out slow though…
May 2, 2006 at 9:54 am
A good read, only thing i disagree with is Zoomr, i think its a shameless copy of flickr with 1 or 2 little aditions. Its not anything special they just took flickrs idea and added a little bit more.
Grrrrr