mysql基础连接查询
<?php $servername = "127.0.0.1"; $username = "root"; $password = "root"; $dbname = "test"; // 创建连接 $conn = mysqli_connect($servername, $username, $password,$dbname); // 检查连接 if (!$conn) { die("连接失败: " . mysqli_connect_error()); } echo "连接成功<br/>"; $sql2 = "SELECT * from users WHERE `id`='1';"; $result=mysqli_query($conn,$sql2); // $row=mysqli_fetch_array($result,MYSQLI_ASSOC); $arr = []; while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){ $arr[] = $row; } print_r($arr); ?>