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>
  • 相关阅读:
    华为徐直军第一次非主场演讲,信息量很大
    智慧城市行业领军企业一览表
    【Python】+Django框架使用
    【Python】+pip超时
    【Python】+web应用开发/界面/Django/Flask
    【Java】+【JSON】+对比两个json对象是否完全一样
    【数据库】+多表查询
    【Java】+MD5生成
    【Java】+操作csv文件
    【Java】+反射1+获取属性/成员变量 的名称及类型
  • 原文地址:https://www.cnblogs.com/SirNie/p/14655988.html
Copyright © 2011-2022 走看看