Thread: Php & Sql
View Single Post
Old 02-02-2008   #2
Hell Puppy
Fat Fucking Nobody
Want to see your own Advertising Here!
 
Hell Puppy's Avatar
 
Join Date: Oct 2002
Posts: 6,523
Default Re: Php & Sql

Quote:
Originally Posted by Nymph View Post
Ok, who is the wiz kid here?

I want to do something with a script I'm running, and not real sure how.

I know I would need to make another table in the sql database I already have for this script...I'm pretty sure I can copy the format of one of the other tables for this.

Next is putting the data in it. I know from what page I need to add it...form style...not sure on the format to get it to insert in the table.

Next is the call to the page for it...big questions on that one.

If anyone would care to give me some pointers, I'd really appreciate it.
Your questions are pretty vague. So my initial suggestion is hit Amazon and find yourself a good PHP and MySQL book that suits your skill level.

I can give you some feedback based on what you say above.

First off, you say you can copy the format of an existing table. No way I can say for sure without knowing EXACTLY what you're doing, but a well designed database is the key to having a maintainable, scalable site that performs well. It starts with your database schema, and thus your table designs.

Before deciding how you want to store data, you must think thru how you want to pull the data back out.

Let's say you're creating a database with recipes in it. Seems simple enough to have a single table in there with all of the fields you might want to capture for each recipe yes? And that indeed would work, but it's gonna be a slug on searchs if the database gets very large, and you may limit your search capabilities or make them require extremely complex sql to extract.

What if I want to search recipes by ingredients? Let's say I want to pull back all recipes that have chicken, tomatoes, and garlic. If I didn't design my schema correctly that's a bitch. If I did, it's easily done and very fast.

Consider another scenario. You store recipes by author. Do I put the author in the recipe table? Or do I cross link to an author table? The correct answer is normally cross link. Why? Many reasons, but what if one of the authors wants to change their "handle" or avatar or email address. If it's all in one table, again, that's one god awful nasty query to write. If it's in a separate table, I update one row and it'll display with the update on every recipe in the database when it's pulled back.

As for taking data from forms and inserting into the database, well, that's a big part of what PHP does and it does it well. It'll collect your form data from the POST or GET, then you can manipulate it as you see fit and use PHP to build SQL statements to pass to MySQL to manipulate the database accordingly.

Again your initial questions are too broad, if you get to a point where they're more narrow such as specific SQL queries you need built, post and I can help.
Hell Puppy is offline   Reply With Quote