Welcome to the bloggy home of Noah Brier. I'm the co-founder of Percolate and general internet tinkerer. This site is about media, culture, technology, and randomness. It's been around since 2004 (I'm pretty sure). Feel free to get in touch. Get in touch.

You can subscribe to this site via RSS (the humanity!) or .

Making Stuff Online

I’ve been spending a lot of time learning PHP/MySQL lately (which is part of the reason I haven’t been blogging all that much). I’ve managed to teach myself to be somewhat proficient with the stuff fairly quickly and I thought maybe it would be fun to share a few tips to getting started. I’m sure many aren’t that interested in learning this stuff, but for those that are, I hope these will help get you over the hump and give it a try.

So, here are a few things you need to know/understand (and if you understand this stuff better than I do, please feel free to correct me).

Databases

They’re basically just big excel spreadsheets. Each table is the equivalent of a sheet in excel. Your goal with a database is to not have a lot of empty cells, so it’s important to separate related data into different tables. For instance, on a blogging platform, you need to separate out comments and entries into different tables. That’s because different entries can and likely will have different amounts of comments. Therefore, if one gets 100 comments and another gets 3, you’d still need to have 100 columns for comments and on the second entry you’d have 97 empty spaces. Make sense?

GET/POST

This is basically how you pass stuff from one webpage to another. When you click a submit button on a form it is likely doing one of these two actions (I actually don’t think it can do anything else). They’re both fairly simple: GET puts whatever you filled in the form in the URL (do a google search and take a look at the location bar) and POST passes the variables invisibly (and according to this page should be used if you’re doing something like inserting the variables into a database or sending an email because GET is easy to mess with).

Moving Stuff to and From Databases

To do pretty much everything I’ve needed to do thus far I’ve only needed a handful of database commands. SELECT grabs stuff from your database. INSERT puts stuff in your database. DELETE (which I’ve used far less frequently), delete’s from the database (surprising huh?). Within those commands you just use WHERE to define the parameters for what row or rows you want to grab (for instance, grab the first name and email for the user with the last name “Brier”).

APIs

This is one of those things lots of people talk about, but few actually understand how they actually work (and I can’t claim to be an expert by any means). Most APIs work by passing them a URL with the data you want in the syntax they’ve defined. They then give you back whatever data you requested (most of the time in XML which you then need to parse). Using Google Maps as an example, they make it super simple to get the latitude and longitude for an address (and you can actually try this without knowing any code at all by signing up for a Google Maps API key for free.

So essentially you need to construct a URL with the address and your API key. It works something like this: http://maps.google.com/maps/geo?q=INSERT ADDRESS HERE WITH +’s INSTEAD OF SPACES&output=DEFINE OUTPUT, IN MY CASE I’M USING CSV (COMMA SEPERATED VALUES)&key=YOUR UNIQUE API KEY. They then return a CSV file with 4 values, the latitude, longitude and two other things I can’t remember (I think zip is one of them). With varying degrees of complexity that’s basically how all the APIs I’ve experiences work.

So, I hope this is somewhat useful/interesting. Part of what inspired me to write this was a quote I read last night in a little book from Electric Artists (who celebrated their 10th anniversary last night): “If you can’t explain it simply, you don’t understand it well enough.” That nugget comes from Albert Einstein and I couldn’t agree more. Obviously there’s lots more to it (I haven’t really even touched on PHP), but these are a few mental hurdles I had before I got started. Hopefully it inspires a few people to give PHP (or some other web language) a shot. It’s really good fun.

April 25, 2008

Comments

  • barbara says:

    Noah, you do a mother’s, and educator’s, heart good:) Here’s another fitting quote:
    “Hear and you forget; see and you remember; do and you understand”(Confucious)

  • Aaron says:

    hey man.. whenever u wanna sit and wax geek on how this stuff works, i LOVE explaining it to people. teaching is an enjoyable past-time of mine, and i’d be more than happy to help you put it into simple terms.. :)

  • Charles says:

    Rock on, man. In addition to Aaron’s brain, this site is pretty solid when it comes to learning all that stuff.

    Also, with regards to programming, I frequently hear people talk about how they’d like to learn it, but there’s something deep in their personality or mental wiring that makes it impossible for them. Maybe they just haven’t heard it in a format that’s digestible to them. I have yet to see a site that quickly and intelligently summarizes the basic concepts of web development, in the way that you do above. Perhaps there’s a need for one…

  • Jeremy says:

    A planner that does code? In a world of labels you might need two ;)

  • Leave a Comment

    Your email address will not be published. Don't sweat it.