ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

create database and table

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • create database and table

    MySQL database:
    A collection of tables, usually they are related in some manner.
    In todays web hosting environment it is possible to host multiple
    websites under one main account. In this case I would recommend
    a seperate database for each site..as well as seperating the forum
    and/or photo galleries in their own database.


    Each hosting site offers their own menu system for administrators
    ...In my current setting
    I just press a button that says "Create New database". I then supply
    description, user ID and password and there you go a new database.


    The MySQL database would be what iseries programmers
    would call a library.CRTLIB

    Once the database is created then in my case I use
    phpmyadmin to create new table within this database.

    I supply the new table name and the number of fields
    in my example the table will be mytest...with 5 fields
    PHP Code:
    CREATE TABLE `mytest` (
    `
    field1INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    `
    field2TEXT NOT NULL ,
    `
    field3SMALLINTNOT NULL ,
    `
    field4DECIMAL30 NOT NULL ,
    `
    field5TIMESTAMP NOT NULL
    TYPE MYISAM COMMENT 'this is my test'

    This would be to an iseries developer --
    create DDS then compile...or create SQL table

    to read from this table we would do something like this

    PHP Code:

    <?php
    //Connect To Database
    $hostname="&DBSERVER";
    $username="&DBUSER";
    $password="&DBPASSWORD";
    $dbname="&DATABASE";
    $usertable="&TABLE";
    $yourfield "&FIELD2";

    mysql_connect($hostname,$username$password
    OR DIE (
    "Unable to connect to database! Please try again later.");
    mysql_select_db($dbname);

    $query "SELECT * FROM $usertable";
    $result mysql_query($query);
    if(
    $result) {
        while(
    $row mysql_fetch_array($result)){
            
    $name $row["$yourfield"];
            echo 
    "Name: ".$name;
        }
    }

    ?>
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com
Working...
X