<?PHP$servername= "localhost"; $username= "Yosha"; $password= "leon0924"; $dbname= "Test";//Create a connection $conn=NewMysqli ($servername,$username,$password,$dbname);//Detecting Connections if($conn-connect_error) { die("Connection failed:".)$conn-connect_error); } $sql= "SELECT * FROM Student"; $result=$conn->query ($sql); if($result->num_rows > 0) { //output per row of data while($row=$result-Fetch_assoc ()) { Echo"<br> number:".$row["SID"]. "Name:".$row["Name"]. "Age:".$row["Age"]; } } Else { Echo"0 Results"; } $conn-Close (); ?>
Due to the latest version of PHP, found in the tutorial MySQL series functions have been discarded, in fact, with the MYSQLI series of functions can, in the configuration of the over-gas MySQL series functions wasted a lot of time, and ultimately useless.
Environment: Xmapp integration Pack (including Apache, MySQL, etc.), netbeans,chrome,win10
Function: Use PHP to access MySQL output "SID", "Name", "Age" column in all data from "student" table in "test" database of "localhost" server
PHP connection MySQL database practiced hand