Creating a Search Application -
(Page 5 of 29 )
A database server can contain many databases. Each database is a container for tables. The reason we would use multiple databases is to keep data for different applications, or users, separate from one another. As we mentioned earlier, we will assume that you are storing your tables in a database named test.
The function we will use to select the database we want to work with is mysql_select_db(). Its syntax is very simple as demonstrated by this code.
<?php mysql_select_db ('test', $db) or die ("Could not select database"); ?> |
The first parameter is the database we want to use and the second is the resource id from the mysql_connect() function. The second parameter is not mandatory if you are only dealing with one database, but it is good practice to use it. By always specifying the resource id, you can avoid complications when you start programming applications that utilize more than one database.
Now that we have connected to our database server and selected the database we want to work with, it's time to put some data into our table and also examine how to retrieve that data.
Next: >>
More Database Articles Articles
More By Matt Wade