We now move on to produce WWW pages that can manipulate databases. To do this, all we have to do is call the appropriate functions of PHP that enable us to pass SQL statements to a MySQL database.
The PHP scripts that follow use these functions:
$c_result = mysql_connect("dbserver.site.com", "dxy3fab", "ind1g0");
Typically, the MySQL server will be configured
so that the username and password
are required when the developer wishes to change a database
but they can be empty strings
when he/she only wishes to inspect the database:
$c_result = mysql_connect("dbserver.site.com", "", "");
$s_result = mysql_select_db("Pdcl0bjc_prices", $c_result);
$q_result = mysql_query("SELECT * FROM consum WHERE price<1.0", $c_result);
$numrows = mysql_num_rows($q_result);
print mysql_result($q_result, $rownum, "price");