Forums | MacLife

You are not logged in.

#1 2003-01-23 2:16 am

ppcman
Member
From: Kensheto
Registered: 2001-09-24
Posts: 70

Help..How do i

I have been having a brain leek for the last week trying to figure out how mySQL and PHP work. Could someone tell me how they work together!
The situation is that i want to make a web page for a jewellery company were people can go to view their products. I have set up PHP on my OS X box and i also have various other packages installed, i configured my apache setup along side aswell. I am hoping to use Dreamweaver as the publishing application and all i need to know is how to make (and what to use) a database with mySQL and then link it to a page.

Any help will be hugly appreciated,


[(-.-)]

Offline

 

#2 2003-01-23 5:23 am

Scott
Zombie Gorilla
From: Oregon
Registered: 2002-12-07
Posts: 3446
Website

Re: Help..How do i

That's a whole lota question there my friend.

My suggestion would be to get a good book on PHP to start with.  Something like Peachpit's Visual Quickstart Guide.  Learn the ins and outs of PHP.  MySql really just sits there and holds data, you will use PHP to store and retrieve the data. 

MySQLadmin is a good web-based interface to help you manage your database.  But you still need to know what you are doing to use it.

DW does have tools for interacting with databases,  it won't create them or manage them, but you can view live data and see the structure.  But it also is really dependent on a good working knowledge of all that is involved.

You might consider looking at hotscripts.com or some place like that to see if you can find something already built that will fit your needs.

---

PHP is a server-side scripting lang designed specifically for the web.  It allows the server to execute scripts that can be written right into html pages.  The server takes a page that is requested and has a specific extension (most commonly .php) and parses any code in it between the delimiters (<? and  ?> most commonly).  The client browser never sees that code.  It is most often used to build pages, store and retrieve data and other fun things.

MySQL is a database for storing relational data.  You use SQL queries to store and retrieve the data.

PHP can send a query to a database in MySQL, and it will return the requested data back to PHP.  You can then display or utilize that data however you see fit.

That's a simplified version of what PHP/MySQL.  It's not a simple process if you don't understand it.  But it is a very powerful set of tools, and only limited by what you can imagine. 

Sorry, I'm just not aware of any simple answers.  They aren't applications like Word or Photoshop, they are tools.

Good Luck.
Scott.


http://www.greatgamesexperiment.com/images/logo_kit/468x60-Blue.gif

Offline

 

#3 2003-01-23 4:58 pm

ppcman
Member
From: Kensheto
Registered: 2001-09-24
Posts: 70

Re: Help..How do i

So i can use Dreamweaver to publish the template (layout) and then make a database where all the data is retrieved to produce the content (Images, information). Is this how it works or am i off the road in a tree?


[(-.-)]

Offline

 

#4 2003-01-23 8:26 pm

TonyPrevite
Slobbering Jester
Royal Wombat
From: Glendale, AZ
Registered: 2002-04-14
Posts: 3606
Website

Re: Help..How do i

Your on the right road,  just don't take the "build a database driven site without coding" exit, it's a dead end big_smile

Offline

 

#5 2003-01-23 10:47 pm

Scott
Zombie Gorilla
From: Oregon
Registered: 2002-12-07
Posts: 3446
Website

Re: Help..How do i

So i can use Dreamweaver to publish the template (layout) and then make a database where all the data is retrieved to produce the content (Images, information). Is this how it works or am i off the road in a tree?

I wouldn't use the term "publish", it can make pages, help write html and manage sites.

What Tony said is on the money.  DW will help, but the database stuff is very cookie cutter, and the effort that it takes to learn how to make DW do what you want would be better spent just learning to code.l


http://www.greatgamesexperiment.com/images/logo_kit/468x60-Blue.gif

Offline

 

#6 2003-01-25 3:15 pm

Galahad
Member
From: Claremont, CA
Registered: 2000-12-31
Posts: 1350
Website

Re: Help..How do i

Yeah, what he said.  Some of my pages are so dispersed between PHP and HTML code that I couldn't imagine using a WYSIWYG editor for them.  A virutal prerequesit for good PHP programming is doing your HTML by hand.  The markup will be better, too.

Offline

 

#7 2003-01-25 4:50 pm

DH
Member
Registered: 2000-06-10
Posts: 1767
Website

Re: Help..How do i

Yeah, what he said.  Some of my pages are so dispersed between PHP and HTML code that I couldn't imagine using a WYSIWYG editor for them.  A virutal prerequesit for good PHP programming is doing your HTML by hand.  The markup will be better, too.

Or, if you have a background as a programmer in more traditional languages (most notably C, C++, or Java) then PHP should be easy to pick up.  I've learned most of what I know about PHP from disecting Dreamweaver's generated code, making my own changes and reading the PHP.net manual.

Offline

 

#8 2003-01-27 3:49 pm

ppcman
Member
From: Kensheto
Registered: 2001-09-24
Posts: 70

Re: Help..How do i

Well i have MySQL all up and going and i was wondering where it stores its databases? and what is its root location? I have figured out that the dir
/usr/local stores most of the critical files but i still cant seem to locate the storage dir for the databases. Also how do you know if you database has been saved.
Guys and Girls.. PHP and MySQL are sure dynamic!


[(-.-)]

Offline

 

#9 2003-01-27 4:15 pm

DH
Member
Registered: 2000-06-10
Posts: 1767
Website

Re: Help..How do i

Well i have MySQL all up and going and i was wondering where it stores its databases? and what is its root location? I have figured out that the dir
/usr/local stores most of the critical files but i still cant seem to locate the storage dir for the databases. Also how do you know if you database has been saved.
Guys and Girls.. PHP and MySQL are sure dynamic!

I'm confused about what you are asking.  If you perform an operation with a query, baring an error, the change is made.  You don't have to choose to save, it saves everything you do automatically.

The databases are stored in /usr/local/mysql/$databasename where $databasename is the name of the specific database you are interested in.  You should not ever need to touch these files.  Although, I suppose you could back them up if you wanted to (but easier methods of backing up a database exist, like performing a dump.)

Getting phpMyAdmin at http://www.phpmyadmin.net/ will help you set up your databases and perform some simple operations without writing any code.  It's not intended as a regular method for administration, but rather as a catch-all so that you don't have to write everything yourself.  To backup a database using this, open your database, then your table and export structure and data (which will dump a text file script of SQL code that will recreate your database for you on any SQL server.)

Offline

 

#10 2003-01-28 11:19 am

ppcman
Member
From: Kensheto
Registered: 2001-09-24
Posts: 70

Re: Help..How do i

Sorry for confusing some people but i'm just trying to get my head around how a dynamic web site works.
I have found an application called YourSQL which enables me to do most of the database work which is good, but i am still wondering about how you go about making the page link to the database.

Note: From what i have gathered a database is where information or the page content is drawn from! Meaning you create a page and instead of linking an image to its location - as such "<img src="/Graphics/image1.png">, you link it to a dbase which in turn retreives the image to display on the page.

Correct me if i'm wrong...


[(-.-)]

Offline

 

#11 2003-01-28 1:21 pm

Scott
Zombie Gorilla
From: Oregon
Registered: 2002-12-07
Posts: 3446
Website

Re: Help..How do i


Note: From what i have gathered a database is where information or the page content is drawn from! Meaning you create a page and instead of linking an image to its location - as such "<img src="/Graphics/image1.png">, you link it to a dbase which in turn retreives the image to display on the page.

Correct me if i'm wrong...

That is wrong.

A database is just that, a base of data.  HTML does not talk to it or link to it in any way.

Let me see if I can illustrate it.  Say you have a data base that is full of names and phone numbers and states.   You have a page that you want to display all the names and phone numbers of the people in Montana.

With php you write a query something like this:

Code:

SELECT * FROM address_db WHERE state = 'Montana"

You utilize php to send that query to the database, and for example you have it return the data in an array.  You then can have php loop through that array and write the HTML that is sent to the browser.

That is pretty generic, but there are many ways to do it depending on your needs and setup. 

In the case of images, you can store the binary data in the database and write it to the browser, but more often you will just store the path to the image, and write that to the page.

Once again, all interaction with the database is done with a scripting language, HTML has nothing to do with it.


http://www.greatgamesexperiment.com/images/logo_kit/468x60-Blue.gif

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson