Create a new view.php file with the following content:
Copy the code The code is as follows:
$ link=mysql_connect("localhost","root","Previous administrator password");
if(!$link) echo "The connection was not successful!";
else echo "The connection was successful!";
?>
In this way, we are connected to the MySQL database. Next, is the code for the data reading part. According to the introduction of my MySQL data source table structure, we experimentally To read:
department varchar(45) department name
ename varchar(45) employee name
pcname varchar(45) PC name
.
Continue writing the previous code in view.php:
Copy the code The code is as follows:
mysql_select_db("infosystem", $link); //Select database
$q = "SELECT * FROM info"; NAMES GB2312");
";
echo "Department name | Employee name | PC name | < /tr>";
while($row = mysql_fetch_row($rs)) echo "
$row[1] | $row[2]< /td> | $row[3] |
"; //Display data
echo "
";
mysql_free_result($rs); /Close the data set
?>
Among them, "infosystem" is the database name and "info" is the table name. You can modify it as appropriate according to your own situation.
Then, run it~how~is the data successfully read?
http://www.bkjia.com/PHPjc/318952.html
www.bkjia.com
truehttp: //www.bkjia.com/PHPjc/318952.htmlTechArticleCreate a new view.php file with the following content: Copy the code as follows: ?php $link=mysql_connect("localhost ","root","Previous administrator password"); if(!$link)echo"The connection was not successful!"; elsee...