Adding a user
 I like the way PostgreSQL works.  It creates a special user for you, pgsql.  This user does all the work.  The database run as this user, and all work
 (database creation, adding users, etc) is done as this user.

 The first step is to add myself as a user, so I don't have to do all my work as pgql.  Here's how I added myself as a user.  I typed the bits in bold.

        $ su -l
        Password:
        [root@set:~] # su pgsql
        $ /usr/local/pgsql/bin/createuser dan
        Shall the new user be allowed to create databases? (y/n) y
        Shall the new user be allowed to create more new users? (y/n) y
        CREATE USER

 Done.  Now that I've added myself as a user who can create databases, I can use my normal login.
 Adding a database
 Now I dropped back to my usual login and created a database.

        $ logout
        [root@set:~] # logout
        [dan@set:/usr/home/dan] $ /usr/local/pgsql/bin/createdb mydb
        CREATE DATABASE

 Done.
 Creating a user for this database
 Now I dropped back to my usual login and created a database.

        $ /usr/local/pgsql/bin/psql mydb
        Welcome to psql, the PostgreSQL interactive terminal.

        Type:  \copyright for distribution terms
               \h for help with SQL commands
               \? for help on internal slash commands
               \g or terminate with semicolon to execute query
               \q to quit

        mydb=# 

 Now I'll create a user, tester,  for this database.

        mydb=# create user tester with password 'mypassword';
        CREATE USER

 Creating a table
 I created a rather simple table for my testing.

        mydb=# create table test (id serial, name varchar(10));
        NOTICE:  CREATE TABLE will create implicit sequence 'test_id_seq' 
                                              for SERIAL column 'test.id'
        NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'test_id_key' 
                                                             for table 'test'
        CREATE

 Then I inserted data:

        mydb=# insert into test (name) values ('test');
        INSERT 18879 1
        mydb=# insert into test (name) values ('test2');
        INSERT 18880 1

 Then I read that data back out:

        freshports2=# select * from test;
         id | name
        ----+-------
          1 | test
          2 | test2
        (2 rows)

 Getting php going
 I create a simple php test in an existing website.  For help on creating websites, look at Apache - virtual hosts.

 I added this to testpsql.php3 in my website.  Note the amended while loop at the end of this section.

        <head>
        <title>PostgreSQL test</title>
        <body>

        <?php
        $database = pg_connect("dbname=mydb user=test password=mypassword");
        if ($database) {
           $result = pg_exec ($database, "select * from test");
           if ($result) {
              echo pg_numrows($result) . " rows to fetch\n";
              echo "<table>\n";
              $i = 0;
              while ($myrow = pg_fetch_array ($result)) {
                 $i++;
                 echo "   <tr><td>" . $myrow["id"] . "</td><td>" . 
                                      $myrow["name"] . "</td></tr>\n";
                 if ($i > 10) break;
              }
              echo "</table>\n";
           } else {
              echo "read from test failed";
           }

           pg_exec ($database, "end");
        } else {
           echo "no connection";
        }
        ?>

        </body></html>    

 As you can see, I had to manually break the loop.  I have no idea why.  I thought pg_fetch_array would return false at the end of the result set, as
 mentioned in the documentation.  But it didn't.  So far, it appears I'll have to use a for  loop for that and not a while.  Any ideas on why 
 pg_fetch_array was behaving like that?  It seems to be standard behaviour.

 A search at http://google.com found this example, which I used to create this amended while loop:

        for ($i = 0; $i < $NumRows; $i++) {             
           $myrow = pg_fetch_array ($result, $i);       
           echo "   <tr><td>" . $myrow["id"] . "</td><td>" . $myrow["name"] . 
                                               "</td></tr>\n";
        }

 What's next?
 I would like a Windows GUI inteface to PostgreSQL.  Any suggestions?   I found ZEOS, but couldn't get it to connect.  I suspect someone wrong
 with my access rights, but I was looking at /usr/local/pgsql/lib/pg_hba.conf.