使用mysqli而不是mysql访问数据库

使用mysqli而不是mysql访问数据库,mysql,phpmyadmin,Mysql,Phpmyadmin,我知道有安全的方法获取数据。我的问题是 我可以用mysqli代替mysql\u查询来改进下面的代码吗 please find below a script in php that that fetch data from my database company, the database is in phpMyadmin 只需用mysqli替换所有mysql 如果你想保持简单 或者像这样做 $result = mysqli_query("SELECT * FROM cust

我知道有安全的方法获取数据。我的问题是 我可以用mysqli代替mysql\u查询来改进下面的代码吗

    please find below a script in php that that fetch data from my database company, the database is in phpMyadmin
只需用mysqli替换所有mysql

如果你想保持简单

或者像这样做

      $result = mysqli_query("SELECT * FROM customer");

      while($row = mysqli_fetch_array( $result )) { 

hi做了一些更改$mysqli=newmysqlilocalhost、我的用户、我的密码、我的数据库、我的数据库;无法很好地选择数据库。如果确实启用了mysqli,请检查PHP.ini文件
      $result = mysqli_query("SELECT * FROM customer");

      while($row = mysqli_fetch_array( $result )) { 
  /*Your connection info goes here...*/
 $mysqli = new mysqli("localhost", "my_user", "my_password", "world");

 if (mysqli_connect_errno()) {
   printf("Connect failed: %s\n", mysqli_connect_error());
   exit();
    }

  $query = "SELECT * FROM customer";

  if ($result = $mysqli->query($query)) {

   echo "<table ><tr><th>ID</th><th>Name</th></tr>"; 

   /* fetch results by row */
   while ($row = $result->fetch_row()) {
    echo "<tr><td>' . $row['CustomerID'].'</td><td>' . $row['Name']. '</td></tr>'; 
   }

  /* free the result set */
  $result->close();
 }

 /* close the connection */
 $mysqli->close();