In this way, we are connected to the MySQL database. Next, is the code for the data reading part."/> In this way, we are connected to the MySQL database. Next, is the code for the data reading part.">
Home >Backend Development >PHP Tutorial >merry lonely christmas PHP read MySQL data code
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 "No connection successful!";
else echo "Connection successful!";
?>
Copy the code The code is as follows:
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 the data set
if(!$rs){die ("Valid result!");}
echo "
Department Name | Employee Name | |
$row[1] | $row[3] |