You can create custom PHP scripts to access your MySQL database.
Below are a few lines of PHP code you can use to access your
database.
<?php
$link = mysql_connect("localhost", "USERNAME", "PASSWORD");
mysql_select_db("DATABASE");
$query = "SELECT * FROM TABLE";
$result = mysql_query($query);
while ($line = mysql_fetch_array($result))
{
foreach ($line as $value)
{
print "$value\n";
}
}
mysql_close($link);
?>
Note that you must replace USERNAME and PASSWORD with your
database user name and password. You must also replace TABLE and
DATABASE with the valid table and database names from your
database. The address of the MySQL database server is localhost; it
is not necessary to include a port number.
To learn more about MySQL, please visit the MySQL web site. To
learn more about PHP, we suggest researching the PHP Group web site.
|