Hello

I am just starting to learn php and mysql. I have some knowledge in html and actionscript for Flash. I wonder if someone might take a little time out of their busy schedule and explain some things to me about php and mysql.

I have several projects that I would like to undertake but am not sure if php and mysql is the right tool. I think I understand how php interacts with the client but am I right in assuming say if you had a guestbook on your website that you could populate a mysql database with their information when they hit the submit button. The database would grow as more people signed your guestbook. Then how would you retrieve the info on the database. Is it sent to you automatically or do you query the database from your computer at home.

Second project. Can you store text files and/or pictures on the mysql database and then call them dynamically from the clients computer so you don't have to store all the pictures on the website making it load slower.

I hope I have made myself clear. I am reading the "PHP and MySQL for Dynamic Web Sites" book and all the forums I can find but sometimes you just need someone to talk to.

Thanks and have a nice day.

Dan

    Hi, Dan:

    I will attempt to answer some of your questions, although I am just learning MYSQL, too.

    1) You could create a database with mutliple tables. Each table could correspond to a project. Sometimes, you will need multiple tables for one project. So, for your site, you might have a DB called: "bbqman_db" and within this you could have a table titled: "guestbook_table" and another titled "images_table", and another called "blog_table" etc...

    2) If you have a form set up to work with a PHP script to validate user input, and sanitize the input for the database, you can then create a query that will enter that info to the DB. Correct.

    3) Then, you would create another page where the information can be displayed, and you would write a companion SQL query to retrieve the data from the database table. You can write the query to show as many or as few items (records) as you wish.

    4) The query is done on the server side of things and not at home on the client. Your job is to present the data selected from the db and format it into correct and valid HTML code for the client.

    5) For images (.gif, .jpg, .jpeg, .png, etc...) and documents (.txt, .doc, .zip, .pdf, etc...) it is best to fill the database with their respective URLs and not the actual content. The performance of the db will be much faster this way, and is typically how it is done.

    Well, I hope that at least points you in the right direction for a couple of your q's.

    Good luck and have fun getting started.

      A browser requests a webpage.
      Request goes to the webserver.

      1-step answer:
      Web server serves the page if it is a static html page.

      BROWSER<->WEBSERVER

      2-step answer:
      Web server passes request to php engine, if the request is a dynamic page, usually with .php extension

      php creates html output, and passes it back to your webser, which in turn sends it to the browser.

      BROWSER<->WEBSERVER<->PHP

      3-step answer:
      If request involves database access,
      browser sends request to webserver,
      webserver hands request to php,
      php sends connects to mysql and sends query,
      mysql executes query, and hands results to php,
      php creates html page, and hands it to webserver,
      webserver sends html page to browser.

      BROWSER<->WEBSERVER<->PHP<->MYSQL

        Thanks for the explanations. I guess I am headed in the right direction just need to keep reading and experimenting.
        Thanks again and I am sure you folks will be hearing from me again real soon.

        Dan

          Write a Reply...