Create a new view.php file with the following contents:
Copy Code code as follows:
<?php
$link =mysql_connect ("localhost", "root", "previous admin password");
if (! $link) echo "No connection succeeded!";
else echo "Connection succeeded!";
?>
In this way, we are connected to the MySQL database, next, is the data read part of the code, according to my MySQL data source table structure of the introduction, we have experimented to read:
Depart varchar (45) Department name
ename varchar (45) Employee name
Pcname varchar (PC) name
These three pieces of data.
In view.php, the preceding code continues to write:
Copy Code code as follows:
<?php
mysql_select_db ("Infosystem", $link); Select Database
$q = "SELECT * from Info"; SQL query Statement
mysql_query ("SET NAMES GB2312");
$rs = mysql_query ($q, $link); Get Data Set
if (! $rs) {die ("Valid result!");}
echo "<table>";
echo "<tr><td> department name </td><td> employee name </TD><TD>PC name </td></tr>";
while ($row = Mysql_fetch_row ($rs)) echo "<tr><td> $row [1]</td><td> $row [2]</td><td > $row [3]</td></tr> "; Display data
echo "</table>";
Mysql_free_result ($RS); Closing datasets
?>
where "Infosystem" is the database name and "Info" is the name of the table. We can revise them according to their own circumstances as appropriate.
Then, run it ~ how ~ the data is not successfully read it?