PHP MySQL? ???? ????.
MySQL ???????? ??? ??
??????? ???? ???? ??? ?????. ? ????? ???????? ???? ?? ???? ???? ??? ?? ?????.
???? ????? select? ?????.
???? td> | ??? ?? | ||||||||
?? ?? | ?? * ?????; | ||||||||
? | select * from MyGuests; | ||||||||
?? ? | MyGuests ???? ?? ?? ?? ?? |
*
"? ????? ???????.?? ????? ????. SQL? ?? ??? ????? SQL ????? ?????.
????
?? MyGuests ???? ??? ???? ????
<?php header("Content-type:text/html;charset=utf-8"); //設置編碼 $servername = "localhost"; $username = "root"; $password = "root"; $dbname = "test"; // 創(chuàng)建連接 $conn = new mysqli($servername, $username, $password, $dbname); // 檢測連接 if ($conn->connect_error) { die("連接失敗: " . $conn->connect_error); } $sql = "SELECT * FROM MyGuests"; $result = $conn->query($sql); if ($result->num_rows > 0) { // 輸出每行數(shù)據 while($row = $result->fetch_assoc()) { echo "id: ". $row["id"]. " - Name: ". $row["firstname"]. " " . $row["lastname"] ." ".$row['email'] ."<br/>"; } } else { echo "0 個結果"; } $conn->close(); ?>???? ?????. ???? ?? ??:
MyGuests ????? ?????.
?? ??? ??? ??? ??? ? ?? ? ?? ????? ?? ?
<?php header("Content-type:text/html;charset=utf-8"); //設置編碼 $servername = "localhost"; $username = "root"; $password = "root"; $dbname = "test"; // 創(chuàng)建連接 $conn = new mysqli($servername, $username, $password, $dbname); // 檢測連接 if ($conn->connect_error) { die("連接失敗: " . $conn->connect_error); } $sql = "SELECT firstname,email FROM MyGuests"; $result = $conn->query($sql); if ($result->num_rows > 0) { // 輸出每行數(shù)據 while($row = $result->fetch_assoc()) { echo " - Name: ". $row["firstname"]. "--------".$row['email'] ."<br/>"; } } else { echo "0 個結果"; } $conn->close(); ?>
? ?? ???? ???. ??> *
? ?? ??? ????: