zoukankan      html  css  js  c++  java
  • 2021.4.13

    mysqli_fetch_row();//用来将查询结果的一行保存至索引数组;

    mysqli_fetch_assoc();//用来将查询结果的一行保存至关联数组;

    mysqli_fetch_array();//前2者的结合。

    1.

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>row</title>
    </head>
    <body>
    <?php
    $conn=mysqli_connect("localhost","root","aliez0.0.","mydate1");
    if(!$conn){
    die("数据库连接失败");
    }
    echo "数据库连接成功";
    echo "<br/>";
    mysqli_query($conn,'set names utf8');

    $sql="select * from student2";
    $result=mysqli_query($conn,$sql)or die("数据查询失败");
    $row=mysqli_fetch_row($result);
    print_r($row);
    echo "<br/>";
    $row=mysqli_fetch_row($result);
    print_r($row);
    ?>
    </body>
    </html>

    2.
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>assoc</title>
    </head>
    <body>
    <?php
    $conn=mysqli_connect("localhost","root","aliez0.0.","mydate1");
    if(!$conn){
    die("数据库连接失败");
    }
    echo "数据库连接成功";
    echo "<br/>";
    mysqli_query($conn,'set names utf8');

    $sql="select * from student2";
    $result=mysqli_query($conn,$sql)or die("数据查询失败");
    $row=mysqli_fetch_assoc($result);
    print_r($row);
    echo "<br/>";
    $row=mysqli_fetch_assoc($result);
    print_r($row);
    ?>
    </body>
    </html>

    3.
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>array</title>
    </head>
    <body>
    <?php
    $conn=mysqli_connect("localhost","root","aliez0.0.","mydate1");
    if(!$conn){
    die("数据库连接失败");
    }
    echo "数据库连接成功";
    echo "<br/>";
    mysqli_query($conn,'set names utf8');

    $sql="select * from student2";
    $result=mysqli_query($conn,$sql)or die("数据查询失败");

    $row=mysqli_fetch_array($result);

    print_r($row);

    echo "<br/>";

    $row=mysqli_fetch_array($result);

    print_r($row);
    ?>
    </body>
    </html>
  • 相关阅读:
    Rsync企业实战之自动异地备份(转)
    Linux启动过程详解 (转)
    Linux系统下修改环境变量PATH路径的三种方法
    linux更改启动级别后,无法启动的问题解决
    MySQLAdmin用法
    mysql toolkit 用法[备忘] (转)
    mysql edit
    MySQL中SSL配置
    mysql ALTER COLUMN MODIFY COLUMN CHANGE COLUMN 区别及用法 (转)
    MySQL 使用mysqld_multi部署单机多实例详细过程 (转)
  • 原文地址:https://www.cnblogs.com/SirNie/p/14655988.html
Copyright © 2011-2022 走看看