Creating a database
In this first example we will create a MySQL database
and then display the contents on the page.
First lets create the database , we will call this
samplelinks . Start up MySQL and enter the following
.
CREATE DATABASE samplelinks;
USE samplelinks;
Here is what is displayed on the screen.
Now we shall create our tablecalled links it will consist
of the url and a brief description of the url , enter
the following .
CREATE TABLE links(url VARCHAR(40) , description
TEXT);
Here is what you should see.
Now lets add some values to the fields . Enter the
following
INSERT INTO links VALUES('http://www.google.com'
, ' The best search engine');
INSERT INTO links VALUES('http://www.beginnersphp.co.uk'
, 'top notch php site');
INSERT INTO links VALUES('http://www.myscripting.com','Scripting
resources galore here');
Here is what is displayed on the screen.
Now we will finally check that everything we have entered
looks good . Enter the following to have a look at your
links table.
SELECT * FROM links ;
Here is what should be displayed .
That is all we will be doing with our table ,of course
you can add more links if you wish but this will do
for our example.
In the next part we will show you how to connect to
the MySQL database and display the links table on your
web page.
|