查詢phpMyAdmin資料表資料
<?php $mysqli = new mysqli('localhost', 'root', '20190129app', 'app_record'); //require"conn.php"; mysqli_set_charset($mysqli, "UTF8"); //$sql = "SELECT * FROM location ORDER BY id ASC LIMIT 1";//取第一行 $sql = "SELECT * FROM location ORDER BY id DESC LIMIT 1";//取最後一行 if (!$result = $mysqli->query($sql)) { // Oh no! The query failed. echo "Sorry, the website is experiencing problems."; // Again, do not do this on a public site, but we'll show you how // to get the error information echo "Error: Our query failed to execute and here is why: \n"; echo "Query: " . $sql . "\n"; echo "Errno: " . $mysqli->errno . "\n"; echo "Error: " . $mysqli->error . "\n"; exit; } if ($result->num_rows === 0) { // Oh, no rows! Sometimes that's expected and okay, sometimes ...