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>
  • 相关阅读:
    ios常见面试题
    UIButton 头文件常见属性和方法
    UILabel头文件常见属性
    UIButton 文档翻译(持续更新)
    UITextView
    iOS国际化
    55分钟学会正则表达式
    提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一,包含通知中心的使用)
    macbook恢复Finder消失的个人收藏:桌面、文稿、下载、图片
    Socket
  • 原文地址:https://www.cnblogs.com/SirNie/p/14655988.html
Copyright © 2011-2022 走看看