Database Articles

  Home arrow Database Articles arrow Page 7 - Create dynamic sites with PHP & MySQL
DATABASE ARTICLES

Create dynamic sites with PHP & MySQL
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 54
    2002-05-19

    Table of Contents:
  • Create dynamic sites with PHP & MySQL
  • Introduction and installation
  • Installing Apache server routines
  • Installing MySQL
  • Installing PHP
  • Your first script
  • Your first database
  • Where's my view?
  • Creating an HTML form
  • Putting it together
  • Passing variables
  • Viewing individual rows
  • Deleting rows
  • Editing data
  • Searching our data
  • Tips for common tasks

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Create dynamic sites with PHP & MySQL - Your first database


    (Page 7 of 16 )

    Now that we have PHP running properly and have created our first script, let's create our first database and see what we can do with it. Drop to console and type in the following command:

    mysqladmin -uroot create learndb

    This creates a database named "learndb" for us to use. Here we have assumed that you are root user. If you are logged in as another user, just use the command mysqladmin -uusername -pyourpassword create learndb, replacing username and yourpassword with your username and password respectively. If you are hosting your site through a hosting company, you probably don't have permission to run mysqladmin. In this case, you have to ask your server administrator to create the database for you.

    Next we will create tables in this database and enter some information. Go to the console. Type:

    mysql

    You should see something like:

    Welcome to MySQL monitor. Commands end with ; or \g. 
    Your MySQL connection id is 5 to server version 3.22.34 
    Type 'help' for help.

    Type:

    CONNECT learndb 
    CREATE TABLE personnel 

    id int NOT NULL AUTO_INCREMENT, 
    firstname varchar(25), 
    lastname varchar(20), 
    nick varchar(12), 
    email varchar(35), 
    salary int, 
    PRIMARY KEY (id), 
    UNIQUE id (id) 
    ); 
    INSERT INTO personnel VALUES ('1', 'John', 'Lever', 'John', 'john@everywhere.net', '75000'); 
    INSERT INTO personnel VALUES ('2', 'Camilla', 'Anderson', 'Rose', 'rose@flower.com', '66000');

    This creates a table with 5 fields and puts some information in it.

    More Database Articles Articles
    More By Codewalkers

    blog comments powered by Disqus

    DATABASE ARTICLES ARTICLES

    - Completing a Book Inventory Management System
    - Uploading Images for a Book Inventory Manage...
    - Finishing the Add Book Story for a Book Inve...
    - Integration Testing for a Book Inventory Man...
    - User Stories for a Book Inventory Management...
    - Unit Testing a Book Inventory Management Sys...
    - Testing a Book Inventory Management System
    - Implementing Models for a Book Inventory Man...
    - Book Inventory Application: Publishers and B...
    - Handling Publishers in a Book Inventory Mana...
    - Publisher Administration for Book Inventory ...
    - Book Inventory Management
    - Using the SQL Reference Manual
    - Using Oracle SQL Developer with SQL Statemen...
    - Fixing Errors with Oracle SQL Developer


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap