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>
  • 相关阅读:
    致初学作曲的业余音乐爱好者 (转载)
    OpenGL教程 "Top Ten" (转载)
    开发者:我们应该在哪个层次编写代码?
    计算机科学数学理论浅谈 (转载)
    fltk2更新简介
    搜集的优良OpenGL教程 (转载)
    [转载] 跨平台C++程序开发系列文章
    通过HtppWebRequest发送图片到服务器并保存
    技术之外
    Hibernate写查询语句注意事项
  • 原文地址:https://www.cnblogs.com/SirNie/p/14655988.html
Copyright © 2011-2022 走看看